Þ¤pathÙE/home/runner/work/course/course/lectures/Generative Classification.jl¬cell_resultsÞ]Ù$0d52466f-b092-4569-8c2d-b43c725887aeЧrunning§runtimeΦv¸depends_on_skipped_cellsµpublished_object_keys�§errored§cell_idÙ$0d52466f-b092-4569-8c2d-b43c725887ae¹depends_on_disabled_cells¦queued¤logs�¦output†¤mime©text/html¬rootassigneeÀ²last_run_timestampËAÚ¹&›'ò•·has_pluto_hook_features¤bodyÚ

Likelihood

Assume a Gaussian class-conditional data-generating distribution with equal covariance matrix across the classes,

$$ p(x_n|\mathcal{C}_{k}) = \mathcal{N}(x_n|\mu_k,\Sigma) \tag{1} $$

with notational shorthand: $\mathcal{C}_{k} \triangleq (y_n \in \mathcal{C}_{k})$.

°persist_js_stateÂÙ$23c689fc-d294-11ef-086e-47c4f871bed2Чrunning§runtimeÍ%g¸depends_on_skipped_cellsµpublished_object_keys�§errored§cell_idÙ$23c689fc-d294-11ef-086e-47c4f871bed2¹depends_on_disabled_cells¦queued¤logs�¦output†¤mime©text/html¬rootassigneeÀ²last_run_timestampËAÚ¹&ž]m·has_pluto_hook_features¤bodyÙíGenerative Classification°persist_js_stateÂÙ$23c7779a-d294-11ef-2e2c-6ba6cadb1381Чrunning§runtimeÎEŒ¸depends_on_skipped_cellsµpublished_object_keys�§errored§cell_idÙ$23c7779a-d294-11ef-2e2c-6ba6cadb1381¹depends_on_disabled_cells¦queued¤logs�¦output†¤mime©text/html¬rootassigneeÀ²last_run_timestampËAÚ¹&›(D€·has_pluto_hook_features¤bodyÚ7

Parameter Estimation

In principle, a full Bayesian treatment requires us to specify prior distributions over the model parameters $\theta = \{ \{\pi_k\}, \{\mu_k\}, \Sigma \}$, and then apply Bayes rule to obtain the corresponding posterior distributions. While this is certainly possible, the mathematics quickly becomes bewildering. Therefore, we opt for maximum likelihood estimation of the parameters as a more practical alternative.

°persist_js_stateÂÙ$f1a40378-a27c-4aa0-a62c-600ffde0032fЧrunning§runtimeÎ ¦ÚH¸depends_on_skipped_cellsµpublished_object_keys�§errored§cell_idÙ$f1a40378-a27c-4aa0-a62c-600ffde0032f¹depends_on_disabled_cells¦queued¤logs�¦output†¤mimeªtext/plain¬rootassigneeÀ²last_run_timestampËAÚ¹&œÓßv·has_pluto_hook_features¤body °persist_js_stateÂÙ$8d78f9d3-7ba8-46b0-8d6f-231e681caa49Чrunning§runtimeΪª¸depends_on_skipped_cellsµpublished_object_keys�§errored§cell_idÙ$8d78f9d3-7ba8-46b0-8d6f-231e681caa49¹depends_on_disabled_cells¦queued¤logs�¦output†¤mime©text/html¬rootassigneeÀ²last_run_timestampËAÚ¹&›)d,·has_pluto_hook_features¤bodyÙ±

Show that the discrimination boundaries for the posterior class probabilities in Eq. (4) evaluates to a line (or hyperplane).

°persist_js_stateÂÙ$70a620bc-47c7-46c4-870b-22b3e05039a1Чrunning§runtimeÎs‹¸depends_on_skipped_cellsµpublished_object_keys�§errored§cell_idÙ$70a620bc-47c7-46c4-870b-22b3e05039a1¹depends_on_disabled_cells¦queued¤logs�¦output†¤mime©text/html¬rootassigneeÀ²last_run_timestampËAÚ¹&›'n·has_pluto_hook_features¤bodyÙn

The features are stored in two matrices, corresponding to the two classes:

°persist_js_stateÂÙ$ffa01b68-c3ba-4509-8df6-00596974be0fЧrunning§runtimeλ&Q¸depends_on_skipped_cellsµpublished_object_keys�§errored§cell_idÙ$ffa01b68-c3ba-4509-8df6-00596974be0f¹depends_on_disabled_cells¦queued¤logs�¦output†¤mimeÙ!application/vnd.pluto.tree+object¬rootassignee¯const plot_lims²last_run_timestampËAÚ¹&¢5À'·has_pluto_hook_features¤bodyƒ¨objectid¯d229199ce2a037b¤typeªNamedTuple¨elements’’¤xlim’ƒ¨objectid°cd5eea3c08ce9968¤type¥Tuple¨elements’’’¤-0.3ªtext/plain’’£3.1ªtext/plainÙ!application/vnd.pluto.tree+object’¤ylim’ƒ¨objectid°d82aabf856b591c8¤type¥Tuple¨elements’’’¤-0.4ªtext/plain’’£4.1ªtext/plainÙ!application/vnd.pluto.tree+object°persist_js_stateÂÙ$866d8e7a-2b33-4635-84c0-6cbf900b523bЧrunning§runtimeΕ8¸depends_on_skipped_cellsµpublished_object_keys�§errored§cell_idÙ$866d8e7a-2b33-4635-84c0-6cbf900b523b¹depends_on_disabled_cells¦queued¤logs�¦output†¤mime©text/html¬rootassigneeÀ²last_run_timestampËAÚ¹&ŸUj·has_pluto_hook_features¤bodyÚE

🎯 Key concept

For the GCM with equal covariances, the posterior class probability is a softmax function,

$$ p(\mathcal{C}_k|x,\theta ) \propto \exp\{\beta_k^T x + \gamma_k\}$$

where $\beta _k= \Sigma^{-1} \mu_k$ and $\gamma_k=- \frac{1}{2} \mu_k^T \Sigma^{-1} \mu_k + \log \pi_k$.

°persist_js_stateÂÙ$ca11db2d-aa15-4bf1-b949-529c7487d11dЧrunning§runtimeÍÑM¸depends_on_skipped_cellsµpublished_object_keys�§errored§cell_idÙ$ca11db2d-aa15-4bf1-b949-529c7487d11d¹depends_on_disabled_cells¦queued¤logs�¦output†¤mime©text/html¬rootassigneeÀ²last_run_timestampËAÚ¹&Ÿ`#æ·has_pluto_hook_features¤bodyÚ×

Exercises

°persist_js_stateÂÙ$845f19c4-c3c5-4368-a48a-a7b57687ddf9Чrunning§runtimeÍ2 ¸depends_on_skipped_cellsµpublished_object_keys�§errored§cell_idÙ$845f19c4-c3c5-4368-a48a-a7b57687ddf9¹depends_on_disabled_cells¦queued¤logs�¦output†¤mime©text/html¬rootassigneeÀ²last_run_timestampËAÚ¹&Ÿ\eI·has_pluto_hook_features¤bodyÚ ö°persist_js_stateÂÙ$20cd1582-d7f7-448c-8685-607f7cc1dc9cЧrunning§runtimeÎ8÷$¸depends_on_skipped_cellsµpublished_object_keys�§errored§cell_idÙ$20cd1582-d7f7-448c-8685-607f7cc1dc9c¹depends_on_disabled_cells¦queued¤logs�¦output†¤mime©text/html¬rootassigneeÀ²last_run_timestampËAÚ¹&Ÿ,üz·has_pluto_hook_features¤bodyÚ[

🎯 Key concept

A common generative model for classification is the Gaussian–Categorical model:

$$p(x_n,\mathcal{C}_k|\,\theta) = \pi_k \cdot \mathcal{N}(x_n|\mu_k,\Sigma) \,,$$

leading to

$$p(x_n,y_n|\,\theta) = \prod_{k=1}^K \big( \pi_k \cdot \mathcal{N}(x|\mu_k,\Sigma)\big)^{y_{nk}} $$

°persist_js_stateÂÙ$19360d53-93d8-46fe-82d5-357015e75e22Чrunning§runtimeÍH¸depends_on_skipped_cellsµpublished_object_keys�§errored§cell_idÙ$19360d53-93d8-46fe-82d5-357015e75e22¹depends_on_disabled_cells¦queued¤logs�¦output†¤mimeÙ!application/vnd.pluto.tree+object¬rootassignee¦Ï€_hat²last_run_timestampËAÚ¹&ŸÏÊ·has_pluto_hook_features¤body…¦prefix§Float64¨objectid°2739f4ba0548eccc¤type¥Array¬prefix_short ¨elements’’’¤0.74ªtext/plain’’¤0.26ªtext/plain°persist_js_stateÂÙ$33d5d6e7-1208-4c5b-b651-429b3b6ad50bЧrunning§runtimeÎ<_¸depends_on_skipped_cellsµpublished_object_keys�§errored§cell_idÙ$33d5d6e7-1208-4c5b-b651-429b3b6ad50b¹depends_on_disabled_cells¦queued¤logs�¦output†¤mimeªtext/plain¬rootassigneeÀ²last_run_timestampËAÚ¹&¡°·has_pluto_hook_features¤bodyÙ.predict_class (generic function with 1 method)°persist_js_stateÂÙ$23c798ce-d294-11ef-0190-f342f30e2266Чrunning§runtimeΰ¸depends_on_skipped_cellsµpublished_object_keys�§errored§cell_idÙ$23c798ce-d294-11ef-0190-f342f30e2266¹depends_on_disabled_cells¦queued¤logs�¦output†¤mime©text/html¬rootassigneeÀ²last_run_timestampËAÚ¹&›( s·has_pluto_hook_features¤bodyÙî

The ML for multinomial class prior (we've done this before!)

$$\begin{align*} \hat \pi_k = \frac{m_k}{N} \end{align*}$$

°persist_js_stateÂÙ$c91ed138-9885-43ce-a00e-1ba6e996f1aaЧrunning§runtimeÎy£Ñ¸depends_on_skipped_cellsµpublished_object_keys�§errored§cell_idÙ$c91ed138-9885-43ce-a00e-1ba6e996f1aa¹depends_on_disabled_cells¦queued¤logs�¦output†¤mimeªtext/plain¬rootassigneeÀ²last_run_timestampËAÚ¹&ŸŒÐзhas_pluto_hook_features¤body °persist_js_stateÂÙ$4ada77d1-09f2-49c7-a44f-1928e0dc5421Чrunning§runtimeÎ nDù¸depends_on_skipped_cellsµpublished_object_keys�§errored§cell_idÙ$4ada77d1-09f2-49c7-a44f-1928e0dc5421¹depends_on_disabled_cells¦queued¤logs�¦output†¤mime­image/svg+xml¬rootassigneeÀ²last_run_timestampËAÚ¹&¥P �·has_pluto_hook_features¤bodyÉÍå °persist_js_stateÂÙ$ba9fa93f-093c-4783-988f-27f4ba228e88Чrunning§runtimeÍxW¸depends_on_skipped_cellsµpublished_object_keys�§errored§cell_idÙ$ba9fa93f-093c-4783-988f-27f4ba228e88¹depends_on_disabled_cells¦queued¤logs�¦output†¤mimeªtext/plain¬rootassignee«Î£_computed²last_run_timestampËAÚ¹& ¿F·has_pluto_hook_features¤bodyÙ†2×2 PDMats.PDMat{Float64, Matrix{Float64}, LinearAlgebra.Cholesky{Float64, Matrix{Float64}}}: 0.255037 0.119649 0.119649 0.381179°persist_js_stateÂÙ$eac2821e-b25c-4605-857a-cd3bd06303c1Чrunning§runtimeÎù $¸depends_on_skipped_cellsµpublished_object_keys�§errored§cell_idÙ$eac2821e-b25c-4605-857a-cd3bd06303c1¹depends_on_disabled_cells¦queued¤logs�¦output†¤mimeªtext/plain¬rootassigneeÀ²last_run_timestampËAÚ¹&ŸåOY·has_pluto_hook_features¤body °persist_js_stateÂÙ$23c7a54c-d294-11ef-0252-ef7a043e995cЧrunning§runtime΃¸depends_on_skipped_cellsµpublished_object_keys�§errored§cell_idÙ$23c7a54c-d294-11ef-0252-ef7a043e995c¹depends_on_disabled_cells¦queued¤logs�¦output†¤mime©text/html¬rootassigneeÀ²last_run_timestampËAÚ¹&›(ºˆ·has_pluto_hook_features¤bodyÚ�

Now group the data into separate classes and do MVG ML estimation for class-conditional parameters (we've done this before as well):

$$\begin{align*} \hat \mu_k &= \frac{ \sum_n y_{nk} x_n} { \sum_n y_{nk} } = \frac{1}{m_k} \sum_n y_{nk} x_n \\ \hat \Sigma &= \frac{1}{N} \sum_{n,k} y_{nk} (x_n-\hat \mu_k)(x_n-\hat \mu_k)^T \\ &= \sum_k \hat \pi_k \cdot \underbrace{ \left( \frac{1}{m_k} \sum_{n} y_{nk} (x_n-\hat \mu_k)(x_n-\hat \mu_k)^T \right) }_{ \text{class-cond. variance} } \\ &= \sum_k \hat \pi_k \cdot \hat \Sigma_k \end{align*}$$

where $\hat \pi_k$, $\hat{\mu}_k$ and $\hat{\Sigma}_k$ are the sample proportion, sample mean and sample variance for the $k$th class, respectively.

°persist_js_stateÂÙ$841ddfc8-85e0-47ee-9288-2d90a84a5dc3Чrunning§runtimeÎG®¸depends_on_skipped_cellsµpublished_object_keys�§errored§cell_idÙ$841ddfc8-85e0-47ee-9288-2d90a84a5dc3¹depends_on_disabled_cells¦queued¤logs�¦output†¤mimeÙ!application/vnd.pluto.tree+object¬rootassignee¡y²last_run_timestampËAÚ¹&Ÿ¬ÃH·has_pluto_hook_features¤body…¦prefix¤Bool¨objectid°5b051a5ea937e692¤type¥Array¬prefix_short ¨elementsÜ’’¤trueªtext/plain’’¤trueªtext/plain’’¤trueªtext/plain’’¤trueªtext/plain’’¤trueªtext/plain’’¤trueªtext/plain’’¥falseªtext/plain’’¤trueªtext/plain’ ’¥falseªtext/plain’ ’¤trueªtext/plain’ ’¤trueªtext/plain’ ’¤trueªtext/plain’ ’¥falseªtext/plain’’¤trueªtext/plain’’¤trueªtext/plain’’¤trueªtext/plain’’¤trueªtext/plain’’¤trueªtext/plain’’¤trueªtext/plain’’¤trueªtext/plain¤more’)’¥falseªtext/plain’*’¥falseªtext/plain’+’¥falseªtext/plain’,’¤trueªtext/plain’-’¤trueªtext/plain’.’¤trueªtext/plain’/’¤trueªtext/plain’0’¤trueªtext/plain’1’¤trueªtext/plain’2’¤trueªtext/plain°persist_js_stateÂÙ$36e6b874-a1b8-40d7-8762-f0c5f9121e40Чrunning§runtimeÎ’%‡¸depends_on_skipped_cellsµpublished_object_keys�§errored§cell_idÙ$36e6b874-a1b8-40d7-8762-f0c5f9121e40¹depends_on_disabled_cells¦queued¤logs�¦output†¤mime­image/svg+xml¬rootassigneeÀ²last_run_timestampËAÚ¹&¤ž7·has_pluto_hook_features¤bodyÉKo °persist_js_stateÂÙ$f63b65b9-86c8-420b-b2d5-28268782f155Чrunning§runtimeÎÝT¸depends_on_skipped_cellsµpublished_object_keys�§errored§cell_idÙ$f63b65b9-86c8-420b-b2d5-28268782f155¹depends_on_disabled_cells¦queued¤logs�¦output†¤mime©text/html¬rootassigneeÀ²last_run_timestampËAÚ¹&›'Xm·has_pluto_hook_features¤bodyÚ%

In the scatter plot, the two features are represented along the two $x$-coordinates, while the fruit label $y \in \{\text{apple}, \text{peach}\}$ is encoded by the marker style.

°persist_js_stateÂÙ$ffc80e65-a454-4b45-a9b7-76b01c7e96c0Чrunning§runtimeÍ鬸depends_on_skipped_cellsµpublished_object_keys�§errored§cell_idÙ$ffc80e65-a454-4b45-a9b7-76b01c7e96c0¹depends_on_disabled_cells¦queued¤logs�¦output†¤mime©text/html¬rootassigneeÀ²last_run_timestampËAÚ¹&Ÿ2™·has_pluto_hook_features¤bodyÚ

Exercise: Evaluate log-likelihood

°persist_js_stateÂÙ$66172ab6-7df8-4068-a748-b33b3f345d6dЧrunning§runtimeÎ7骸depends_on_skipped_cellsµpublished_object_keys�§errored§cell_idÙ$66172ab6-7df8-4068-a748-b33b3f345d6d¹depends_on_disabled_cells¦queued¤logs�¦output†¤mime©text/html¬rootassigneeÀ²last_run_timestampËAÚ¹&Ÿ€Ÿà·has_pluto_hook_features¤bodyÚ ¯
Click for the solution
  • (a) We choose $C_1$ if $p(C_1|x)/p(C_2|x) > 1$. This condition can be worked out as

$$\frac{p(C_1|x)}{p(C_2|x)} = \frac{p(x|C_1)p(C_1)}{p(x|C_2)p(C_2)} = \frac{10 \times 0.6}{200(x-1)\times 0.4}>1 $$

which evaluates to choosing

$$\mathrm{Decision} = \begin{cases} C_1 & \text{ if $1.0\leq x < 1.075$} \\ C_2 & \text{ if $1.075 \leq x \leq 1.1$ } \end{cases}$$

The probability that $x$ falls outside the interval $[1.0,1.1]$ is zero.

  • (b) The total probability of error is

$$p(\text{error})=\int_x p(\text{error}|x)p(x) \mathrm{d}{x} \,.$$

We can work this out as

$$\begin{align*} p(\text{error}) &= \int_x p(\text{error}|x)p(x)\mathrm{d}{x}\\ &= \int_{1.0}^{1.075} p(C_2|x)p(x) \mathrm{d}{x} + \int_{1.075}^{1.1} p(C_1|x)p(x) \mathrm{d}{x}\\ &= \int_{1.0}^{1.075} p(x|C_2)p(C_2) \mathrm{d}{x} + \int_{1.075}^{1.1} p(x|C_1)p(C_1) \mathrm{d}{x}\\ &= \int_{1.0}^{1.075}0.4\cdot 200(x-1) \mathrm{d}{x} + \int_{1.075}^{1.1} 0.6\cdot 10 \mathrm{d}{x}\\ &=80\cdot[x^2/2-x]_{1.0}^{1.075} + 6\cdot[x]_{1.075}^{1.1}\\ &=0.225 + 0.15\\ &=0.375 \end{align*}$$

°persist_js_stateÂÙ$3228f074-7c1d-420a-bfb0-c3bd693003adЧrunning§runtimeÎÁ)¸depends_on_skipped_cellsµpublished_object_keys�§errored§cell_idÙ$3228f074-7c1d-420a-bfb0-c3bd693003ad¹depends_on_disabled_cells¦queued¤logs�¦output†¤mime©text/html¬rootassigneeÀ²last_run_timestampËAÚ¹&›)É—·has_pluto_hook_features¤bodyÙ±

Our model assumes that both distributions have the same covariance matrix. We get this in practice by taking the weighted average of the two:

°persist_js_stateÂÙ$23c763ce-d294-11ef-015b-736be1a5e9d6Чrunning§runtimeΈ«¸depends_on_skipped_cellsµpublished_object_keys�§errored§cell_idÙ$23c763ce-d294-11ef-015b-736be1a5e9d6¹depends_on_disabled_cells¦queued¤logs�¦output†¤mime©text/html¬rootassigneeÀ²last_run_timestampËAÚ¹&›(,·has_pluto_hook_features¤bodyÙÁ

As usual, once the model has been specified, the rest (inference for parameters and application) can be executed through straight probability theory.

°persist_js_stateÂÙ$fe9d4fbc-f264-459b-8fbe-26663500f6c5Чrunning§runtimeί%é¸depends_on_skipped_cellsµpublished_object_keys�§errored§cell_idÙ$fe9d4fbc-f264-459b-8fbe-26663500f6c5¹depends_on_disabled_cells¦queued¤logs�¦output†¤mime©text/html¬rootassigneeÀ²last_run_timestampËAÚ¹&ž{O‹·has_pluto_hook_features¤bodyÚP¾ °persist_js_stateÂÙ$23c6997e-d294-11ef-09a8-a50563e5975bЧrunning§runtimeÎ Öݸdepends_on_skipped_cellsµpublished_object_keys�§errored§cell_idÙ$23c6997e-d294-11ef-09a8-a50563e5975b¹depends_on_disabled_cells¦queued¤logs�¦output†¤mime©text/html¬rootassigneeÀ²last_run_timestampËAÚ¹&›'?Ý·has_pluto_hook_features¤bodyÚÒ

Preliminaries

Goal
Materials
°persist_js_stateÂÙ$23c7baa4-d294-11ef-22c1-31b0d86f5586Чrunning§runtimeÎ Œ3¸depends_on_skipped_cellsµpublished_object_keys�§errored§cell_idÙ$23c7baa4-d294-11ef-22c1-31b0d86f5586¹depends_on_disabled_cells¦queued¤logs�¦output†¤mime©text/html¬rootassigneeÀ²last_run_timestampËAÚ¹&ŸJE·has_pluto_hook_features¤bodyÚ\

Application: Class prediction for new Data

the posterior class probability

Let's apply the trained model to predict the class for a "new" input $x_\bullet$:

$$\begin{align*} p(\mathcal{C}_k|x_\bullet,D ) &= \int p(\mathcal{C}_k|x_\bullet,\theta ) p(\theta|D) \mathrm{d}\theta \\ &= \sigma\left( \beta_k^T x_\bullet + \gamma_k\right) \tag{4} \end{align*}$$

where

$$\sigma(a)_k \triangleq \frac{\exp(a_k)}{\sum_{k^\prime}\exp(a_{k^\prime})}$$

is called a softmax (a.k.a., normalized exponential) function, and

$$\begin{align*} \beta_k &= \hat{\Sigma}^{-1} \hat{\mu}_k \\ \gamma_k &= - \frac{1}{2} \hat{\mu}_k^T \hat{\Sigma}^{-1} \hat{\mu}_k + \log \hat{\pi}_k \end{align*}$$

°persist_js_stateÂÙ$5730758d-80cd-4d95-b16c-399c38cf585bЧrunning§runtimeÎJ´¸depends_on_skipped_cellsµpublished_object_keys�§errored§cell_idÙ$5730758d-80cd-4d95-b16c-399c38cf585b¹depends_on_disabled_cells¦queued¤logs�¦output†¤mime©text/html¬rootassigneeÀ²last_run_timestampËAÚ¹&›'‚Ô·has_pluto_hook_features¤bodyÙp

Bayesian Generative Classification

°persist_js_stateÂÙ$69732524-90fd-46f4-9706-c07ce6226d2bЧrunning§runtimeÎUÇàá¸depends_on_skipped_cellsµpublished_object_keys�§errored§cell_idÙ$69732524-90fd-46f4-9706-c07ce6226d2b¹depends_on_disabled_cells¦queued¤logs�¦output†¤mime­image/svg+xml¬rootassigneeÀ²last_run_timestampËAÚ¹&£œ·has_pluto_hook_features¤bodyÈÈ °persist_js_stateÂÙ$c79525b1-7b44-4585-8292-84abe20a1a3dЧrunning§runtime΄þ¸depends_on_skipped_cellsµpublished_object_keys�§errored§cell_idÙ$c79525b1-7b44-4585-8292-84abe20a1a3d¹depends_on_disabled_cells¦queued¤logs�¦output†¤mime©text/html¬rootassigneeÀ²last_run_timestampËAÚ¹&›+.·has_pluto_hook_features¤bodyÙ+

Markers

°persist_js_stateÂÙ$e8cbfc78-04dd-4196-8011-90283969e5b1Чrunning§runtimeÍÌ|¸depends_on_skipped_cellsµpublished_object_keys�§errored§cell_idÙ$e8cbfc78-04dd-4196-8011-90283969e5b1¹depends_on_disabled_cells¦queued¤logs�¦output†¤mime©text/html¬rootassignee¬peach_marker²last_run_timestampËAÚ¹&¥hnÊ·has_pluto_hook_features¤bodyÙú °persist_js_stateÂÙ$e65e0e33-3e4f-4765-84ea-a4fb5d43269eЧrunning§runtimeÎa¸depends_on_skipped_cellsµpublished_object_keys�§errored§cell_idÙ$e65e0e33-3e4f-4765-84ea-a4fb5d43269e¹depends_on_disabled_cells¦queued¤logs�¦output†¤mime©text/html¬rootassigneeÀ²last_run_timestampËAÚ¹&›*ø'·has_pluto_hook_features¤bodyÙ4

Code

°persist_js_stateÂÙ$10bfb9ea-46a6-4f4d-980e-ed2afce7b39aЧrunning§runtimeÎ225ý¸depends_on_skipped_cellsµpublished_object_keys�§errored§cell_idÙ$10bfb9ea-46a6-4f4d-980e-ed2afce7b39a¹depends_on_disabled_cells¦queued¤logs�¦output†¤mimeªtext/plain¬rootassignee¢d1²last_run_timestampËAÚ¹& }‚b·has_pluto_hook_features¤bodyÙ—FullNormal( dim: 2 μ: [0.949339261361238, 1.0748205362633203] Σ: [0.2906072276723124 0.15494386501056617; 0.15494386501056617 0.43524154851099617] ) °persist_js_stateÂÙ$cff683bf-0488-41d2-9858-cf8776a48992Чrunning§runtimeÍ )¸depends_on_skipped_cellsµpublished_object_keys�§errored§cell_idÙ$cff683bf-0488-41d2-9858-cf8776a48992¹depends_on_disabled_cells¦queued¤logs�¦output†¤mimeÙ!application/vnd.pluto.tree+object¬rootassigneeÀ²last_run_timestampËAÚ¹& H¡·has_pluto_hook_features¤bodyƒ¨objectid°88186c284eb73ad8¤type¥Tuple¨elements’’’Ú 37×2 Matrix{Float64}: 1.14288 0.991106 0.285831 0.789316 1.34803 0.569492 0.655883 1.04051 1.84175 1.56492 0.606654 0.878951 0.470538 2.47187 â‹® 1.46277 1.11098 0.732683 1.79238 0.361115 1.16743 0.1447 0.585737 1.43844 1.50046 1.00434 1.03604ªtext/plain’’Ùÿ13×2 Matrix{Float64}: 2.53453 2.66332 1.30288 2.34834 2.22687 4.01909 1.5529 2.57325 2.24966 2.65981 2.34839 2.41456 1.22962 2.65432 2.21624 2.13585 1.83426 2.89929 1.97245 2.13648 1.89919 3.0358 1.68315 3.14117 1.61073 2.60747ªtext/plain°persist_js_stateÂÙ$23c7ab20-d294-11ef-1926-afae49e79923Чrunning§runtimeÎ’X¸depends_on_skipped_cellsµpublished_object_keys�§errored§cell_idÙ$23c7ab20-d294-11ef-1926-afae49e79923¹depends_on_disabled_cells¦queued¤logs�¦output†¤mime©text/html¬rootassigneeÀ²last_run_timestampËAÚ¹&›(Ô|·has_pluto_hook_features¤bodyÙž

Note that the binary class selection variable $y_{nk}$ groups data from the same class.

°persist_js_stateÂÙ$24a08e5c-c2c1-4f1f-a2c1-998b30147e61Чrunning§runtimeÎ×·¸depends_on_skipped_cellsµpublished_object_keys�§errored§cell_idÙ$24a08e5c-c2c1-4f1f-a2c1-998b30147e61¹depends_on_disabled_cells¦queued¤logs�¦output†¤mime©text/html¬rootassigneeÀ²last_run_timestampËAÚ¹&›*ÅÒ·has_pluto_hook_features¤bodyÚ

Fanta or Orangina? (**)

You have a machine that measures property $x$, the "orangeness" of liquids. You wish to discriminate between $C_1 = \text{`Fanta'}$ and $C_2 = \text{`Orangina'}$. It is known that

$$\begin{align*} p(x|C_1) &= \begin{cases} 10 & 1.0 \leq x \leq 1.1\\ 0 & \text{otherwise} \end{cases}\\ p(x|C_2) &= \begin{cases} 200(x - 1) & 1.0 \leq x \leq 1.1\\ 0 & \text{otherwise} \end{cases} \end{align*}$$

The prior probabilities $p(C_1) = 0.6$ and $p(C_2) = 0.4$ are also known from experience.

$$ \text{Decision} = \begin{cases} C_1 & \text{if } p(C_1|x)>p(C_2|x) \\ C_2 & \text{otherwise} \end{cases}$$

Derive the optimal Bayes classifier.

$$p(\text{error}|x)= p(C_1|\text{we-decide-} C_2, x) + p(C_2|\text{we-decide-}C_1, x)$$

Compute the total error probability $p(\text{error})$ for the Bayes classifier in this example.

°persist_js_stateÂÙ$23c85d90-d294-11ef-375e-7101d4d3cbfaЧrunning§runtimeÎ3H¸depends_on_skipped_cellsµpublished_object_keys�§errored§cell_idÙ$23c85d90-d294-11ef-375e-7101d4d3cbfa¹depends_on_disabled_cells¦queued¤logs�¦output†¤mime©text/html¬rootassigneeÀ²last_run_timestampËAÚ¹&›*su·has_pluto_hook_features¤bodyÚ ò

Why Be Bayesian?

A student in one of the previous years posed the following question at Piazza:

"After re-reading topics regarding generative classification, this question popped into my mind: Besides the sole purpose of the lecture, which is getting to know the concepts of generative classification and how to implement them, are there any advantages of using this instead of using deep neural nets (DNN), as they seem simpler and more powerful?"

The following answer was provided:

If you are only interested in approximating a function, and you have lots of examples of desired behavior, then often a non-probabilistic DNN is a fine approach. However, if you are willing to formulate your models in a probabilistic framework, you can frequently improve on the deterministic approach in many ways. We list a few below:

1. Bayesian Evidence as a Performance Metric

2. Parameter Uncertainty Enables Active Learning

3. Predictions with Confidence Bounds

4. Explicit and Modular Assumptions

5. Unified Treatment of Accuracy and Complexity

6. Data-Dependent, Optimal Learning Rates

7. Principled Knowledge Transfer

Admittedly, the probabilistic approach can be challenging to grasp at first, but the effort often pays off. It provides a principled, flexible, and robust framework for reasoning under uncertainty.

°persist_js_stateÂÙ$1a890e4b-b8a9-4a6e-b1f3-17863e1416d7Чrunning§runtimeÍÞ˸depends_on_skipped_cellsµpublished_object_keys�§errored§cell_idÙ$1a890e4b-b8a9-4a6e-b1f3-17863e1416d7¹depends_on_disabled_cells¦queued¤logs�¦output†¤mime©text/html¬rootassigneeÀ²last_run_timestampËAÚ¹&ŸYAê·has_pluto_hook_features¤bodyÚ

Challenge Revisited: Apple or Peach

°persist_js_stateÂÙ$3842654e-6dd7-427c-bb77-8b35a2f324fbЧrunning§runtimeÎü)¸depends_on_skipped_cellsµpublished_object_keys�§errored§cell_idÙ$3842654e-6dd7-427c-bb77-8b35a2f324fb¹depends_on_disabled_cells¦queued¤logs�¦output†¤mimeªtext/plain¬rootassigneeÀ²last_run_timestampËAÚ¹&ŸŒ+·has_pluto_hook_features¤body °persist_js_stateÂÙ$e91effb4-b3ac-4d7a-b93f-33a78a125110Чrunning§runtimeÎu ¸depends_on_skipped_cellsµpublished_object_keys�§errored§cell_idÙ$e91effb4-b3ac-4d7a-b93f-33a78a125110¹depends_on_disabled_cells¦queued¤logs�¦output†¤mime©text/html¬rootassigneeÀ²last_run_timestampËAÚ¹&›)é·has_pluto_hook_features¤bodyÙh

We now have class-conditional Gaussian distributions for each class:

°persist_js_stateÂÙ$a985e1d3-4867-4991-a60e-e85a9730311bЧrunning§runtimeΖí̸depends_on_skipped_cellsµpublished_object_keys�§errored§cell_idÙ$a985e1d3-4867-4991-a60e-e85a9730311b¹depends_on_disabled_cells¦queued¤logs�¦output†¤mime©text/html¬rootassignee¬apple_marker²last_run_timestampËAÚ¹&¥]ù]·has_pluto_hook_features¤bodyÙü °persist_js_stateÂÙ$23c7c920-d294-11ef-1b6d-d98dd54dcbe3Чrunning§runtimeÎ1ó¸depends_on_skipped_cellsµpublished_object_keys�§errored§cell_idÙ$23c7c920-d294-11ef-1b6d-d98dd54dcbe3¹depends_on_disabled_cells¦queued¤logs�¦output†¤mime©text/html¬rootassigneeÀ²last_run_timestampËAÚ¹&›(좷has_pluto_hook_features¤bodyÚT
The softmax function

The softmax function can be viewed as a smooth approximation to the maximum function. Importantly, we did not impose the softmax posterior by assumption; rather, it emerged naturally by applying Bayes rule to our chosen prior and likelihood models.

°persist_js_stateÂÙ$21602809-d98b-43d7-8c41-80dc8de6da57Чrunning§runtimeÎ[Ù¸depends_on_skipped_cellsµpublished_object_keys�§errored§cell_idÙ$21602809-d98b-43d7-8c41-80dc8de6da57¹depends_on_disabled_cells¦queued¤logs�¦output†¤mime©text/html¬rootassigneeÀ²last_run_timestampËAÚ¹&›*·has_pluto_hook_features¤bodyÙL

Closing Thoughts

°persist_js_stateÂÙ$14362031-7977-4a0c-b329-23da9b5b2f62Чrunning§runtime΄´¸depends_on_skipped_cellsµpublished_object_keys�§errored§cell_idÙ$14362031-7977-4a0c-b329-23da9b5b2f62¹depends_on_disabled_cells¦queued¤logs�¦output†¤mime©text/html¬rootassigneeÀ²last_run_timestampËAÚ¹&ŸE©·has_pluto_hook_features¤bodyÚY

🎯 Key concept

ML estimation for $\{\pi_k,\mu_k,\Sigma\}$ in the GCM model breaks down to simple density estimation for Gaussian and multinomial/categorical distributions.

°persist_js_stateÂÙ$5092090d-cfac-4ced-b61e-fb7107a4c638Чrunning§runtimeÎj¸depends_on_skipped_cellsµpublished_object_keys�§errored§cell_idÙ$5092090d-cfac-4ced-b61e-fb7107a4c638¹depends_on_disabled_cells¦queued¤logs�¦output†¤mime©text/html¬rootassigneeÀ²last_run_timestampËAÚ¹&›)°ê·has_pluto_hook_features¤bodyÙÒ

Estimate class-conditional distributions

Now, for each class, we fit a Gaussian distribution to the data of that class:

°persist_js_stateÂÙ$23c7f170-d294-11ef-1340-fbdf4ce5fd44Чrunning§runtimeΜ¸depends_on_skipped_cellsµpublished_object_keys�§errored§cell_idÙ$23c7f170-d294-11ef-1340-fbdf4ce5fd44¹depends_on_disabled_cells¦queued¤logs�¦output†¤mime©text/html¬rootassigneeÀ²last_run_timestampËAÚ¹&›)Lù·has_pluto_hook_features¤bodyÚÑ

Therefore, the contours of equal probability (also known as discriminant functions, or decision boundaries), given by

$$\log \frac{{p(\mathcal{C}_k|x,D )}}{{p(\mathcal{C}_j|x,D )}} \overset{!}{=} 0 \,,$$

are lines (hyperplanes) in the feature space.

°persist_js_stateÂÙ$23c82e10-d294-11ef-286a-ff6fee0f2805Чrunning§runtimeÎZ_¸depends_on_skipped_cellsµpublished_object_keys�§errored§cell_idÙ$23c82e10-d294-11ef-286a-ff6fee0f2805¹depends_on_disabled_cells¦queued¤logs�¦output†¤mime©text/html¬rootassigneeÀ²last_run_timestampËAÚ¹&¥td¦·has_pluto_hook_features¤bodyÚv

We'll apply the above results to solve the "apple or peach " example problem.

°persist_js_stateÂÙ$4481b38d-dc67-4c1f-ac0b-b348f0aea461Чrunning§runtimeÎp ¸depends_on_skipped_cellsµpublished_object_keys�§errored§cell_idÙ$4481b38d-dc67-4c1f-ac0b-b348f0aea461¹depends_on_disabled_cells¦queued¤logs�¦output†¤mime©text/html¬rootassigneeÀ²last_run_timestampËAÚ¹&›)˜Ý·has_pluto_hook_features¤bodyÙÏ

Implementation Issues

We can fit a Bernouilly distribution to y (see definition), this is simple:

°persist_js_stateÂÙ$23c7e4a0-d294-11ef-16e9-6f96a41baf97Чrunning§runtimeÎ㬸depends_on_skipped_cellsµpublished_object_keys�§errored§cell_idÙ$23c7e4a0-d294-11ef-16e9-6f96a41baf97¹depends_on_disabled_cells¦queued¤logs�¦output†¤mime©text/html¬rootassigneeÀ²last_run_timestampËAÚ¹&›))··has_pluto_hook_features¤bodyÚ

Discrimination Boundaries

The class log-posterior $\log p(\mathcal{C}_k|x) \propto \beta_k^T x + \gamma_k$ is a linear function of the input features.

°persist_js_stateÂÙ$cc8144d9-9ecf-4cbd-aea9-0c7a2fca2d94Чrunning§runtimeÍbd¸depends_on_skipped_cellsµpublished_object_keys�§errored§cell_idÙ$cc8144d9-9ecf-4cbd-aea9-0c7a2fca2d94¹depends_on_disabled_cells¦queued¤logs�¦output†¤mimeªtext/plain¬rootassignee«p_apple_est²last_run_timestampËAÚ¹&ŸÂ°`·has_pluto_hook_features¤body¤0.74°persist_js_stateÂÙ$46d2d5e9-bb6b-409a-acdc-cdffd1a6f797Чrunning§runtimeÍbx¸depends_on_skipped_cellsµpublished_object_keys�§errored§cell_idÙ$46d2d5e9-bb6b-409a-acdc-cdffd1a6f797¹depends_on_disabled_cells¦queued¤logs�¦output†¤mimeÙ!application/vnd.pluto.tree+object¬rootassignee¬conditionals²last_run_timestampËAÚ¹& å™·has_pluto_hook_features¤body…¦prefixÙŒDistributions.FullNormal{Float64, PDMats.PDMat{Float64, Matrix{Float64}, LinearAlgebra.Cholesky{Float64, Matrix{Float64}}}, Vector{Float64}}¨objectid°90d396cae6e71d0a¤type¥Array¬prefix_short ¨elements’’’ÙXFullNormal( dim: 2 μ: [0.949339, 1.07482] Σ: [0.255037 0.119649; 0.119649 0.381179] ) ªtext/plain’’ÙWFullNormal( dim: 2 μ: [1.89699, 2.71452] Σ: [0.255037 0.119649; 0.119649 0.381179] ) ªtext/plain°persist_js_stateÂÙ$6631c0e4-4941-442e-8dd4-fa307ee7a8c0Чrunning§runtimeÎ!W¸depends_on_skipped_cellsµpublished_object_keys�§errored§cell_idÙ$6631c0e4-4941-442e-8dd4-fa307ee7a8c0¹depends_on_disabled_cells¦queued¤logs�¦output†¤mimeªtext/plain¬rootassigneeÀ²last_run_timestampËAÚ¹&�dvŸ·has_pluto_hook_features¤body °persist_js_stateÂÙ$358fac57-7458-40b5-9f69-50ad4ca7eddeЧrunning§runtimeÍ.4¸depends_on_skipped_cellsµpublished_object_keys�§errored§cell_idÙ$358fac57-7458-40b5-9f69-50ad4ca7edde¹depends_on_disabled_cells¦queued¤logs�¦output†¤mime©text/html¬rootassigneeÀ²last_run_timestampËAÚ¹&Ÿ]�²·has_pluto_hook_features¤bodyÚK
°persist_js_stateÂÙ$25e18c78-9cac-4faa-bb7c-ac036d0eac90Чrunning§runtimeÎ=î¸depends_on_skipped_cellsµpublished_object_keys�§errored§cell_idÙ$25e18c78-9cac-4faa-bb7c-ac036d0eac90¹depends_on_disabled_cells¦queued¤logs�¦output†¤mime©text/html¬rootassigneeÀ²last_run_timestampËAÚ¹&ŸV«u·has_pluto_hook_features¤bodyÚ,
Click for the solution

$$\begin{align} &\log \frac{{p(\mathcal{C}_k|x,D )}}{{p(\mathcal{C}_j|x,D )}} \overset{!}{=} 0 \\ \implies &\frac{\beta_k^T x + \gamma_k}{\beta_j^T x + \gamma_j} = 1 \\ \implies &\beta_k^T x + \gamma_k = \beta_j^T x + \gamma_j \\ \implies &\beta_{kj}^T x + \gamma_{kj} = 0 \quad \text{(this is a line)}\,, \end{align}$$

where we defined $\beta_{kj} \triangleq \beta_k - \beta_j$ and similarly for $\gamma_{kj}$.

°persist_js_stateÂÙ$a42ec280-a88a-485b-9f34-219b370e5784Чrunning§runtimeÍ$Ú¸depends_on_skipped_cellsµpublished_object_keys�§errored§cell_idÙ$a42ec280-a88a-485b-9f34-219b370e5784¹depends_on_disabled_cells¦queued¤logs�¦output†¤mime©text/html¬rootassigneeÀ²last_run_timestampËAÚ¹&Ÿ‚;%·has_pluto_hook_features¤bodyÚ† °persist_js_stateÂÙ$ef1e5885-7153-4b55-9f97-1e984c2504e6Чrunning§runtime΀¸depends_on_skipped_cellsµpublished_object_keys�§errored§cell_idÙ$ef1e5885-7153-4b55-9f97-1e984c2504e6¹depends_on_disabled_cells¦queued¤logs�¦output†¤mime©text/html¬rootassigneeÀ²last_run_timestampËAÚ¹&Ÿ€Îî·has_pluto_hook_features¤bodyÚ.
Click for the solution

Substitute 4.64 into 4.58 to get

$$\begin{align*} a &= \log \left( \frac{ \frac{1}{(2\pi)^{D/2}} \cdot \frac{1}{|\Sigma|^{1/2}} \cdot \exp\left( -\frac{1}{2}(x-\mu_1)^T \Sigma^{-1} (x-\mu_1)\right) \cdot p(C_1)}{\frac{1}{(2\pi)^{D/2}} \cdot \frac{1}{|\Sigma|^{1/2}}\cdot \exp\left( -\frac{1}{2}(x-\mu_2)^T \Sigma^{-1} (x-\mu_2)\right) \cdot p(C_2)}\right) \\ &= \log \left( \exp\left(-\frac{1}{2}(x-\mu_1)^T \Sigma^{-1} (x-\mu_1) + \frac{1}{2}(x-\mu_2)^T \Sigma^{-1} (x-\mu_2) \right) \right) + \log \frac{p(C_1)}{p(C_2)} \\ &\qquad\vdots \\ &=( \mu_1-\mu_2)^T\Sigma^{-1}x - 0.5\left(\mu_1^T\Sigma^{-1}\mu_1 - \mu_2^T\Sigma^{-1} \mu_2\right)+ \log \frac{p(C_1)}{p(C_2)} \end{align*}$$

Substituting this into the right-most form of (4.57) we obtain (4.65), with $w$ and $w0$ given by (4.66) and (4.67), respectively.

°persist_js_stateÂÙ$23c82154-d294-11ef-0945-c9c94fc2a44dЧrunning§runtimeη¸depends_on_skipped_cellsµpublished_object_keys�§errored§cell_idÙ$23c82154-d294-11ef-0945-c9c94fc2a44d¹depends_on_disabled_cells¦queued¤logs�¦output†¤mime©text/html¬rootassigneeÀ²last_run_timestampËAÚ¹&›)M·has_pluto_hook_features¤bodyÚÓ

Making a Decision

How should we classify a new input $x_\bullet$?

The Bayesian answer is to compute the posterior distribution over classes,

$$p(\mathcal{C}_k | x_\bullet,D)\,,$$

and this completes the classification task: the posterior encapsulates all available information about class membership given the input and data.

If a definite classification must be made, a natural choice is the class with the highest posterior probability:

$$\begin{align*} k^* &= \arg\max_k p(\mathcal{C}_k|x_\bullet,D) \\ &= \arg\max_k \left( \beta _k^T x_\bullet + \gamma_k \right) \end{align*}$$

This corresponds to a maximum a posteriori (MAP) decision rule, which is both simple and effective in many practical settings.

°persist_js_stateÂÙ$50cbe27e-009f-4df1-b80a-cf1e73fc525eЧrunning§runtimeÎEf¸depends_on_skipped_cellsµpublished_object_keys�§errored§cell_idÙ$50cbe27e-009f-4df1-b80a-cf1e73fc525e¹depends_on_disabled_cells¦queued¤logs�¦output†¤mimeªtext/plain¬rootassigneeÀ²last_run_timestampËAÚ¹&ž1¯Š·has_pluto_hook_features¤body °persist_js_stateÂÙ$bf39f423-7df3-4990-a254-c28a1bdf23bfЧrunning§runtimeÍ1͸depends_on_skipped_cellsµpublished_object_keys�§errored§cell_idÙ$bf39f423-7df3-4990-a254-c28a1bdf23bf¹depends_on_disabled_cells¦queued¤logs�¦output†¤mimeÙ!application/vnd.pluto.tree+object¬rootassigneeÀ²last_run_timestampËAÚ¹&¢ð·has_pluto_hook_features¤body…¦prefix§Float64¨objectid°be2baf7d6b0233aa¤type¥Array¬prefix_short ¨elements’’’£2.3ªtext/plain’’£1.5ªtext/plain°persist_js_stateÂÙ$90b862a5-d5bc-4122-a942-f01062daa86aЧrunning§runtimeÎbÿ¸depends_on_skipped_cellsµpublished_object_keys�§errored§cell_idÙ$90b862a5-d5bc-4122-a942-f01062daa86a¹depends_on_disabled_cells¦queued¤logs�¦output†¤mime©text/html¬rootassigneeÀ²last_run_timestampËAÚ¹&¥d^¢·has_pluto_hook_features¤bodyÚA

Posterior class probability of $x_∙$ (prediction)

Now we can answer the question from the challenge, and calculate the probability that $x_∙$ is an apple .

°persist_js_stateÂÙ$b01a4a56-bed2-4a06-991a-831adc84aa3eЧrunning§runtimeÎA¸depends_on_skipped_cellsµpublished_object_keys�§errored§cell_idÙ$b01a4a56-bed2-4a06-991a-831adc84aa3e¹depends_on_disabled_cells¦queued¤logs�¦output†¤mime©text/html¬rootassigneeÀ²last_run_timestampËAÚ¹&ŸVùH·has_pluto_hook_features¤bodyÚÁ
Click for the solution

Following the same derivation as above (in the cell "Click for proof of (4)"), the posterior class probability evaluates to

$$\begin{align*} p(\mathcal{C}_k|x_\bullet,D ) \propto \exp \Big\{ \underbrace{-\frac{1}{2}x_\bullet^T \hat{\Sigma}_k^{ - 1} x_\bullet}_{\text{now a function of }k} + \underbrace{\hat{\mu}_k^T \hat{\Sigma}_k^{-1}}_{\beta_k^T} x_\bullet \underbrace{- {\frac{1}{2}}\hat{\mu}_k^T \hat{\Sigma}_k^{ - 1} \hat{\mu}_k + \log \hat{\pi}_k }_{\gamma_k} \Big\} \,. \end{align*}$$

Because the quadratic term $x_\bullet^T \hat{\Sigma}_k^{-1} x_\bullet$ is now class-dependent, the decision boundaries are given by quadratic equations in $x$. Hence, the decision boundaries are generally (hyper-)ellipsoid surfaces.

°persist_js_stateÂÙ$117f3f65-a9bd-4b25-93e2-42ac1e576b6dЧrunning§runtimeγp¸depends_on_skipped_cellsµpublished_object_keys�§errored§cell_idÙ$117f3f65-a9bd-4b25-93e2-42ac1e576b6d¹depends_on_disabled_cells¦queued¤logs�¦output†¤mime©text/html¬rootassigneeÀ²last_run_timestampËAÚ¹&ŸVÏî·has_pluto_hook_features¤bodyÚ�

🎯 Key concept

If the class-conditional distributions are Gaussian with equal covariance matrices across classes (i.e., $\Sigma_k = \Sigma$), then the discriminant functions are hyperplanes in feature space.

°persist_js_stateÂÙ$fe324e92-d753-46cd-aad9-794a76dc806bЧrunning§runtimeÎÄÒݸdepends_on_skipped_cellsµpublished_object_keys�§errored§cell_idÙ$fe324e92-d753-46cd-aad9-794a76dc806b¹depends_on_disabled_cells¦queued¤logs�¦output†¤mime©text/html¬rootassigneeÀ²last_run_timestampËAÚ¹&¥\Ĭ·has_pluto_hook_features¤bodyÚ^

You are also given a test fruit , which has known feature values but an unknown fruit label.

°persist_js_stateÂÙ$a8adaf31-bee2-40e9-8d9b-bb9f1ad996caЧrunning§runtimeÎD~¸depends_on_skipped_cellsµpublished_object_keys�§errored§cell_idÙ$a8adaf31-bee2-40e9-8d9b-bb9f1ad996ca¹depends_on_disabled_cells¦queued¤logs�¦output†¤mime©text/html¬rootassigneeÀ²last_run_timestampËAÚ¹&›)}$·has_pluto_hook_features¤bodyÚ`

Now assume that the class-conditional feature distributions are modeled with class-dependent covariance matrices, i.e.,

$$ p(x_n|\mathcal{C}_{k}) = \mathcal{N}(x_n|\mu_k,\Sigma_k) $$

What do the decision boundaries look like in this case?

°persist_js_stateÂÙ$7e5213d6-4a68-4843-ab4c-77ea3ed8b0cdЧrunning§runtimeÎ�N¸depends_on_skipped_cellsµpublished_object_keys�§errored§cell_idÙ$7e5213d6-4a68-4843-ab4c-77ea3ed8b0cd¹depends_on_disabled_cells¦queued¤logs�¦output†¤mime©text/html¬rootassigneeÀ²last_run_timestampËAÚ¹&›*â?·has_pluto_hook_features¤bodyÚa

Bishop exercise 4.8 (**)

Using (4.57) and (4.58) (from Bishop's book), derive the result (4.65) for the posterior class probability in the two-class generative model with Gaussian densities, and verify the results (4.66) and (4.67) for the parameters $w$ and $w0$.

°persist_js_stateÂÙ$f1575443-c9fb-4674-bbce-bf3a5a6d5a8dЧrunning§runtimeÎKK¸¸depends_on_skipped_cellsµpublished_object_keys�§errored§cell_idÙ$f1575443-c9fb-4674-bbce-bf3a5a6d5a8d¹depends_on_disabled_cells¦queued¤logs�¦output†¤mimeªtext/plain¬rootassigneeÀ²last_run_timestampËAÚ¹&�½¿·has_pluto_hook_features¤body °persist_js_stateÂÙ$23c73b54-d294-11ef-0ef8-8d9159139a1bЧrunning§runtimeÎ CÚ¸depends_on_skipped_cellsµpublished_object_keys�§errored§cell_idÙ$23c73b54-d294-11ef-0ef8-8d9159139a1b¹depends_on_disabled_cells¦queued¤logs�¦output†¤mime©text/html¬rootassigneeÀ²last_run_timestampËAÚ¹&›'Ô·has_pluto_hook_features¤bodyÚå

Model Specification

Representation

The above data set will be represented as $D = \{(x_1,y_1),\dotsc,(x_N,y_N)\}$, where

  • inputs $x_n \in \mathbb{R}^M$ are called features.

  • outputs $y_n \in \mathcal{C}_k$, with $k=1,\ldots,K$; The discrete targets $\mathcal{C}_k$ are called classes.

Similar to our representation of the categorical distribution, we will again use the 1-of-K (or one-hot) encoding to represent the discrete class labels. We define binary class selection variables

$$y_{nk} = \begin{cases} 1 & \text{if } \, y_n \in \mathcal{C}_k\\ 0 & \text{otherwise} \end{cases}$$

Hence, the notations $y_{nk}=1$ and $y_n \in \mathcal{C}_k$ mean the same thing.

°persist_js_stateÂÙ$77280f3b-e391-482f-936f-703d1d3c4006Чrunning§runtimeή¸depends_on_skipped_cellsµpublished_object_keys�§errored§cell_idÙ$77280f3b-e391-482f-936f-703d1d3c4006¹depends_on_disabled_cells¦queued¤logs�¦output†¤mime©text/html¬rootassigneeÀ²last_run_timestampËAÚ¹&¥qµR·has_pluto_hook_features¤bodyÚ:
Problem
  • Based on the observed data, what is the probability that the test fruit is an apple , and not a peach ?

Solution
°persist_js_stateÂÙ$24d3c1f4-432f-419f-8854-69d8bfc135f8Чrunning§runtimeÎx¨®¸depends_on_skipped_cellsµpublished_object_keys�§errored§cell_idÙ$24d3c1f4-432f-419f-8854-69d8bfc135f8¹depends_on_disabled_cells¦queued¤logs�¦output†¤mimeªtext/plain¬rootassigneeÀ²last_run_timestampËAÚ¹&Ÿñ1·has_pluto_hook_features¤body °persist_js_stateÂÙ$23c73302-d294-11ef-0c12-571686b202a9Чrunning§runtimeÎ� ¸depends_on_skipped_cellsµpublished_object_keys�§errored§cell_idÙ$23c73302-d294-11ef-0c12-571686b202a9¹depends_on_disabled_cells¦queued¤logs�¦output†¤mime©text/html¬rootassigneeÀ²last_run_timestampËAÚ¹&›'£‡·has_pluto_hook_features¤bodyÚÔ

The plan for generative classification is as follows: We begin by constructing a model for the joint distribution

$$p(x, y) = p(x | y)\, p(y),$$

which combines a class-conditional likelihood $p(x | y)$ with a prior $p(y)$ over classes. Then, we apply Bayes rule to compute the posterior class probabilities,

$$p(y|x) = \frac{p(x|y) p(y)}{\sum_{y^\prime} p(x|y^\prime) p(y^\prime)} \propto p(x|y)\,p(y)$$

This posterior can then be used for classification by selecting the class with the highest probability.

Next, we discuss the three modeling stages: (1) model specification, (2) parameter learning, (3) application (classification).

°persist_js_stateÂÙ$fedb7530-6fce-496c-a55a-3e9908f9711aЧrunning§runtimeÎ#=¸depends_on_skipped_cellsµpublished_object_keys�§errored§cell_idÙ$fedb7530-6fce-496c-a55a-3e9908f9711a¹depends_on_disabled_cells¦queued¤logs�¦output†¤mimeªtext/plain¬rootassigneeÀ²last_run_timestampËAÚ¹&Ÿ¸‚{·has_pluto_hook_features¤bodyÙ4"11111101011101111111011111101011010010110001111111"°persist_js_stateÂÙ$23c75dc8-d294-11ef-3c57-614e75f06d8fЧrunning§runtimeÎT’¸depends_on_skipped_cellsµpublished_object_keys�§errored§cell_idÙ$23c75dc8-d294-11ef-3c57-614e75f06d8f¹depends_on_disabled_cells¦queued¤logs�¦output†¤mime©text/html¬rootassigneeÀ²last_run_timestampËAÚ¹&Ÿ"ÿ·has_pluto_hook_features¤bodyÚñ

We will refer to this model (specified by Eqs. 1 and 2) as the Gaussian-Categorical Model (GCM).

  • N.B. In the literature, this model (with possibly unequal $\Sigma_k$ across classes) is often called the Gaussian Discriminant Analysis model and the special case with equal covariance matrices $\Sigma_k=\Sigma$ is also called Linear Discriminant Analysis. We think these names are a bit unfortunate as it may lead to confusion with the discriminative method for classification.

°persist_js_stateÂÙ$79fa1b47-460f-457e-aebc-646f60ffecc1Чrunning§runtimeÎHX¸depends_on_skipped_cellsµpublished_object_keys�§errored§cell_idÙ$79fa1b47-460f-457e-aebc-646f60ffecc1¹depends_on_disabled_cells¦queued¤logs�¦output†¤mime©text/html¬rootassignee®unknown_marker²last_run_timestampËAÚ¹&¥W¿ä·has_pluto_hook_features¤bodyÙÍ °persist_js_stateÂÙ$d9efe8bb-c32c-40f4-89d9-8ace7a0665baЧrunning§runtimeÍHϸdepends_on_skipped_cellsµpublished_object_keys�§errored§cell_idÙ$d9efe8bb-c32c-40f4-89d9-8ace7a0665ba¹depends_on_disabled_cells¦queued¤logs�¦output†¤mimeÙ!application/vnd.pluto.tree+object¬rootassignee¦x_test²last_run_timestampËAÚ¹&¡�É·has_pluto_hook_features¤body…¦prefix§Float64¨objectid°be2baf7d6b0233aa¤type¥Array¬prefix_short ¨elements’’’£2.3ªtext/plain’’£1.5ªtext/plain°persist_js_stateÂÙ$23c74748-d294-11ef-2170-bf45b6379e4dЧrunning§runtimeθdepends_on_skipped_cellsµpublished_object_keys�§errored§cell_idÙ$23c74748-d294-11ef-2170-bf45b6379e4d¹depends_on_disabled_cells¦queued¤logs�¦output†¤mime©text/html¬rootassigneeÀ²last_run_timestampËAÚ¹&›( �·has_pluto_hook_features¤bodyÚ

Prior

We use a categorical distribution for the class labels $y_{nk}$:

$$p(\mathcal{C}_{k}) = \pi_k \tag{2}$$

°persist_js_stateÂÙ$9973e8e5-4744-4ff6-9494-1c93503f11c1Чrunning§runtimeÎϸdepends_on_skipped_cellsµpublished_object_keys�§errored§cell_idÙ$9973e8e5-4744-4ff6-9494-1c93503f11c1¹depends_on_disabled_cells¦queued¤logs�¦output†¤mime©text/html¬rootassigneeÀ²last_run_timestampËAÚ¹&¥d´g·has_pluto_hook_features¤bodyÚ}

We can use this function on every point of the plot, to draw a heatmap of apple probability:

°persist_js_stateÂÙ$723e09fc-ec63-4c47-844c-d821515ce0f4Чrunning§runtimeÎwÁÌÔ¸depends_on_skipped_cellsµpublished_object_keys�§errored§cell_idÙ$723e09fc-ec63-4c47-844c-d821515ce0f4¹depends_on_disabled_cells¦queued¤logs�¦output†¤mime©text/html¬rootassigneeÀ²last_run_timestampËAÚ¹&¡ïjè·has_pluto_hook_features¤bodyÙI

\(p(\text{apple}|x=x_∙) = 0.679\)

°persist_js_stateÂÙ$876f47d8-b272-4e23-b5ec-5c7d615ff618Чrunning§runtimeÎ)!ò’¸depends_on_skipped_cellsµpublished_object_keys�§errored§cell_idÙ$876f47d8-b272-4e23-b5ec-5c7d615ff618¹depends_on_disabled_cells¦queued¤logs�¦output†¤mime©text/html¬rootassigneeÀ²last_run_timestampËAÚ¹&žþ²§·has_pluto_hook_features¤bodyÚ ö°persist_js_stateÂÙ$f7a19975-a919-4659-9b6a-d8963a1cd6d9Чrunning§runtimeÎ9Áó¸depends_on_skipped_cellsµpublished_object_keys�§errored§cell_idÙ$f7a19975-a919-4659-9b6a-d8963a1cd6d9¹depends_on_disabled_cells¦queued¤logs�¦output†¤mime©text/html¬rootassigneeÀ²last_run_timestampËAÚ¹&žœW ·has_pluto_hook_features¤bodyÚô

Challenge: Apple or Peach?

°persist_js_stateÂÙ$23c78d3e-d294-11ef-0309-ff10f58f0252Чrunning§runtimeÎŽP¸depends_on_skipped_cellsµpublished_object_keys�§errored§cell_idÙ$23c78d3e-d294-11ef-0309-ff10f58f0252¹depends_on_disabled_cells¦queued¤logs�¦output†¤mime©text/html¬rootassigneeÀ²last_run_timestampËAÚ¹&›(‰¹·has_pluto_hook_features¤bodyÚÍ

Maximization of log-likelihood

Maximization of the LLH for the GDA model breaks down into

  • Gaussian density estimation for parameters $\mu_k, \Sigma$, since the first term contains exactly the log-likelihood for MVG density estimation. We've already done this; see the Density Estimation lesson.

  • Multinomial density estimation for class priors $\pi_k$, since the second term holds exactly the log-likelihood for multinomial density estimation. We've also done this before; see the Density Estimation lesson.

°persist_js_stateÂÙ$689ea1f9-0a72-478e-b8a9-ebf450ce95efЧrunning§runtimeÍ&%¸depends_on_skipped_cellsµpublished_object_keys�§errored§cell_idÙ$689ea1f9-0a72-478e-b8a9-ebf450ce95ef¹depends_on_disabled_cells¦queued¤logs�¦output†¤mime©text/html¬rootassigneeÀ²last_run_timestampËAÚ¹&Ÿ[Í·has_pluto_hook_features¤bodyÚ ö°persist_js_stateÂÙ$5c746070-19a9-464b-aedc-401d016dfdb6Чrunning§runtimeͽ¼¸depends_on_skipped_cellsµpublished_object_keys�§errored§cell_idÙ$5c746070-19a9-464b-aedc-401d016dfdb6¹depends_on_disabled_cells¦queued¤logs�¦output†¤mime©text/html¬rootassigneeÀ²last_run_timestampËAÚ¹&ŸV€R·has_pluto_hook_features¤bodyÚ

Exercise: Discrimination boundaries

°persist_js_stateÂÙ$2f2cb20f-ff7c-4b7f-8aa0-f5b3addb9299Чrunning§runtimeÎg¸depends_on_skipped_cellsµpublished_object_keys�§errored§cell_idÙ$2f2cb20f-ff7c-4b7f-8aa0-f5b3addb9299¹depends_on_disabled_cells¦queued¤logs�¦output†¤mime©text/html¬rootassigneeÀ²last_run_timestampËAÚ¹&ŸU5Ê·has_pluto_hook_features¤bodyÚ �
°persist_js_stateÂÙ$2e1ccf78-6097-4097-8bc8-1f1ec2d9c3ffЧrunning§runtimeÎ-ظdepends_on_skipped_cellsµpublished_object_keys�§errored§cell_idÙ$2e1ccf78-6097-4097-8bc8-1f1ec2d9c3ff¹depends_on_disabled_cells¦queued¤logs�¦output†¤mime©text/html¬rootassigneeÀ²last_run_timestampËAÚ¹&›(] ·has_pluto_hook_features¤bodyÚ

Show that the log-likelihood for the parameters evaluates to

$$\log\, p(D|\theta) = \sum_{n,k} y_{nk} \underbrace{ \log\mathcal{N}(x_n|\mu_k,\Sigma) }_{ \text{see Gaussian lecture} } + \underbrace{ \sum_k m_k \log \pi_k }_{ \text{see multinomial lecture} } \tag{3}$$

where we used $m_k \triangleq \sum_n y_{nk}$.

°persist_js_stateÂÙ$84353cd1-e4fb-4689-9e90-d8995cbe2e9bЧrunning§runtimeÎ�ñw¸depends_on_skipped_cellsµpublished_object_keys�§errored§cell_idÙ$84353cd1-e4fb-4689-9e90-d8995cbe2e9b¹depends_on_disabled_cells¦queued¤logs�¦output†¤mime©text/html¬rootassigneeÀ²last_run_timestampËAÚ¹&ŸR�?·has_pluto_hook_features¤bodyÚ¸
Click for proof of (4)

$$\begin{align*} p(\mathcal{C}_k|x_\bullet,D ) &= \int p(\mathcal{C}_k|x_\bullet,\theta ) \underbrace{p(\theta|D)}_{=\delta(\theta - \hat{\theta})} \mathrm{d}\theta \\ &= p(\mathcal{C}_k|x_\bullet,\hat{\theta} ) \\ &\propto p(\mathcal{C}_k)\,p(x_\bullet|\mathcal{C}_k) \\ &= \hat{\pi}_k \cdot \mathcal{N}(x_\bullet | \hat{\mu}_k, \hat{\Sigma}) \\ &\propto \hat{\pi}_k \exp \left\{ { - {\frac{1}{2}}(x_\bullet - \hat{\mu}_k )^T \hat{\Sigma}^{ - 1} (x_\bullet - \hat{\mu}_k )} \right\}\\ &=\exp \Big\{ \underbrace{-\frac{1}{2}x_\bullet^T \hat{\Sigma}^{ - 1} x_\bullet}_{\text{not a function of }k} + \underbrace{\hat{\mu}_k^T \hat{\Sigma}^{-1}}_{\beta_k^T} x_\bullet \underbrace{- {\frac{1}{2}}\hat{\mu}_k^T \hat{\Sigma}^{ - 1} \hat{\mu}_k + \log \hat{\pi}_k }_{\gamma_k} \Big\} \\ &\propto \frac{1}{Z}\exp\{\beta_k^T x_\bullet + \gamma_k\} \\ &= \sigma\left( \beta_k^T x_\bullet + \gamma_k\right) \end{align*}$$

°persist_js_stateÂÙ$51a46b5e-0c35-4841-a4f3-413d5d294805Чrunning§runtimeÎ_

You're given the numerical values for two features (let's say, sugar content and acidity) of a bunch of fruits. Each piece of fruit is either an apple or a peach .

Generate this data yourself by selecting the total number of fruits with the slider:

°persist_js_stateÂÙ$32cb67f6-1ed2-4d30-8493-e4eed9651526Чrunning§runtimeίZ¸depends_on_skipped_cellsµpublished_object_keys�§errored§cell_idÙ$32cb67f6-1ed2-4d30-8493-e4eed9651526¹depends_on_disabled_cells¦queued¤logs�¦output†¤mime©text/html¬rootassigneeÀ²last_run_timestampËAÚ¹&ŸDä‚·has_pluto_hook_features¤bodyÚ
Click for the solution

$$\begin{align*} \log\, p(D|\theta) &= \log \prod_n p(x_n,y_n|\theta ) \quad \text{(assume IID data)} \\ &= \sum_n \log p(x_n,y_n|\theta ) \\ &= \sum_n \log \prod_k p(x_n,y_{nk}=1\,|\,\theta)^{y_{nk}} \\ &= \sum_{n,k} y_{nk} \log p(x_n,y_{nk}=1\,|\,\theta) \\ &= \sum_{n,k} y_{nk} \log p(x_n|y_{nk}=1) + \sum_{n,k} y_{nk} \log p(y_{nk}=1) \\ &= \sum_{n,k} y_{nk} \log\mathcal{N}(x_n|\mu_k,\Sigma) + \sum_{n,k} y_{nk} \log \pi_k \\ &= \sum_{n,k} y_{nk} \log\mathcal{N}(x_n|\mu_k,\Sigma)+ \sum_k m_k \log \pi_k \end{align*}$$

°persist_js_stateÂÙ$26853cdc-0644-4f44-b6db-b5624a4a8689Чrunning§runtimeÎD£¸depends_on_skipped_cellsµpublished_object_keys�§errored§cell_idÙ$26853cdc-0644-4f44-b6db-b5624a4a8689¹depends_on_disabled_cells¦queued¤logs�¦output†¤mimeªtext/plain¬rootassigneeÀ²last_run_timestampËAÚ¹&�Ýÿ½·has_pluto_hook_features¤body °persist_js_stateÂÙ$cd310392-aabd-40e0-b06f-f8297c7eed6fЧrunning§runtimeÎ0Á¸depends_on_skipped_cellsµpublished_object_keys�§errored§cell_idÙ$cd310392-aabd-40e0-b06f-f8297c7eed6f¹depends_on_disabled_cells¦queued¤logs�¦output†¤mimeªtext/plain¬rootassignee¢d2²last_run_timestampËAÚ¹& }·has_pluto_hook_features¤bodyÙšFullNormal( dim: 2 μ: [1.8969911206691994, 2.7145191810999716] Σ: [0.1537986547189379 0.019192849403146705; 0.019192849403146705 0.22730831605172588] ) °persist_js_stateÂÙ$a4463d74-04ea-428a-b5a5-504d96432a0aЧrunning§runtimeÎÛ2¸depends_on_skipped_cellsµpublished_object_keys�§errored§cell_idÙ$a4463d74-04ea-428a-b5a5-504d96432a0a¹depends_on_disabled_cells¦queued¤logs�¦output†¤mime©text/html¬rootassigneeÀ²last_run_timestampËAÚ¹&›+·has_pluto_hook_features¤bodyÚ6

Our data is structured as follows:

°persist_js_stateÂÙ$45f1f80d-18fc-465c-aaf3-54bbcd8bc95eЧrunning§runtimeÎp»¸depends_on_skipped_cellsµpublished_object_keys�§errored§cell_idÙ$45f1f80d-18fc-465c-aaf3-54bbcd8bc95e¹depends_on_disabled_cells¦queued¤logs�¦output†¤mime©text/html¬rootassigneeÀ²last_run_timestampËAÚ¹&›*ŠL·has_pluto_hook_features¤bodyÙ:

Summary

°persist_js_state±published_objects€­julia_version§v1.13.3±cell_dependenciesÞ]Ù$0d52466f-b092-4569-8c2d-b43c725887ae„´precedence_heuristic §cell_idÙ$0d52466f-b092-4569-8c2d-b43c725887ae´downstream_cells_map€²upstream_cells_map‚§@md_str�¨getindex�Ù$23c689fc-d294-11ef-086e-47c4f871bed2„´precedence_heuristic §cell_idÙ$23c689fc-d294-11ef-086e-47c4f871bed2´downstream_cells_map€²upstream_cells_map�¥title�Ù$23c7779a-d294-11ef-2e2c-6ba6cadb1381„´precedence_heuristic §cell_idÙ$23c7779a-d294-11ef-2e2c-6ba6cadb1381´downstream_cells_map€²upstream_cells_map‚§@md_str�¨getindex�Ù$f1a40378-a27c-4aa0-a62c-600ffde0032f„´precedence_heuristic§cell_idÙ$f1a40378-a27c-4aa0-a62c-600ffde0032f´downstream_cells_map�²BmlipTeachingTools�²upstream_cells_map€Ù$8d78f9d3-7ba8-46b0-8d6f-231e681caa49„´precedence_heuristic §cell_idÙ$8d78f9d3-7ba8-46b0-8d6f-231e681caa49´downstream_cells_map€²upstream_cells_map‚§@md_str�¨getindex�Ù$70a620bc-47c7-46c4-870b-22b3e05039a1„´precedence_heuristic §cell_idÙ$70a620bc-47c7-46c4-870b-22b3e05039a1´downstream_cells_map€²upstream_cells_map‚§@md_str�¨getindex�Ù$ffa01b68-c3ba-4509-8df6-00596974be0f„´precedence_heuristic §cell_idÙ$ffa01b68-c3ba-4509-8df6-00596974be0f´downstream_cells_map�©plot_lims“Ù$69732524-90fd-46f4-9706-c07ce6226d2bÙ$36e6b874-a1b8-40d7-8762-f0c5f9121e40Ù$4ada77d1-09f2-49c7-a44f-1928e0dc5421²upstream_cells_map€Ù$866d8e7a-2b33-4635-84c0-6cbf900b523b„´precedence_heuristic §cell_idÙ$866d8e7a-2b33-4635-84c0-6cbf900b523b´downstream_cells_map€²upstream_cells_mapƒ§@md_str�¨getindex�ªkeyconcept�Ù$ca11db2d-aa15-4bf1-b949-529c7487d11d„´precedence_heuristic §cell_idÙ$ca11db2d-aa15-4bf1-b949-529c7487d11d´downstream_cells_map€²upstream_cells_map�©exercises�Ù$845f19c4-c3c5-4368-a48a-a7b57687ddf9„´precedence_heuristic §cell_idÙ$845f19c4-c3c5-4368-a48a-a7b57687ddf9´downstream_cells_map€²upstream_cells_map�¦N_bond‘Ù$876f47d8-b272-4e23-b5ec-5c7d615ff618Ù$20cd1582-d7f7-448c-8685-607f7cc1dc9c„´precedence_heuristic §cell_idÙ$20cd1582-d7f7-448c-8685-607f7cc1dc9c´downstream_cells_map€²upstream_cells_mapƒ§@md_str�¨getindex�ªkeyconcept�Ù$19360d53-93d8-46fe-82d5-357015e75e22„´precedence_heuristic §cell_idÙ$19360d53-93d8-46fe-82d5-357015e75e22´downstream_cells_map�¦Ï€_hat’Ù$ba9fa93f-093c-4783-988f-27f4ba228e88Ù$33d5d6e7-1208-4c5b-b651-429b3b6ad50b²upstream_cells_map‚«p_apple_est‘Ù$cc8144d9-9ecf-4cbd-aea9-0c7a2fca2d94¡-�Ù$33d5d6e7-1208-4c5b-b651-429b3b6ad50b„´precedence_heuristic §cell_idÙ$33d5d6e7-1208-4c5b-b651-429b3b6ad50b´downstream_cells_map�­predict_class’Ù$723e09fc-ec63-4c47-844c-d821515ce0f4Ù$4ada77d1-09f2-49c7-a44f-1928e0dc5421²upstream_cells_map‰¡/�¦Vector�¦Ï€_hat‘Ù$19360d53-93d8-46fe-82d5-357015e75e22£pdf�¡+�¤Real�¥Int64�¬conditionals‘Ù$46d2d5e9-bb6b-409a-acdc-cdffd1a6f797¡*�Ù$23c798ce-d294-11ef-0190-f342f30e2266„´precedence_heuristic §cell_idÙ$23c798ce-d294-11ef-0190-f342f30e2266´downstream_cells_map€²upstream_cells_map‚§@md_str�¨getindex�Ù$c91ed138-9885-43ce-a00e-1ba6e996f1aa„´precedence_heuristic §cell_idÙ$c91ed138-9885-43ce-a00e-1ba6e996f1aa´downstream_cells_map�®p_apple_secret‘Ù$841ddfc8-85e0-47ee-9288-2d90a84a5dc3²upstream_cells_map�©Bernoulli�Ù$4ada77d1-09f2-49c7-a44f-1928e0dc5421„´precedence_heuristic §cell_idÙ$4ada77d1-09f2-49c7-a44f-1928e0dc5421´downstream_cells_map€²upstream_cells_map�¥cgrad�¬LaTeXStrings‘Ù$50cbe27e-009f-4df1-b80a-cf1e73fc525e¦@L_str�©plot_lims‘Ù$ffa01b68-c3ba-4509-8df6-00596974be0f¨scatter!�¦x_test‘Ù$d9efe8bb-c32c-40f4-89d9-8ace7a0665ba¥range�¥plot!�¡:�­predict_class‘Ù$33d5d6e7-1208-4c5b-b651-429b3b6ad50b¨heatmap!�¸LaTeXStrings.latexstring�©X_peaches‘Ù$24d3c1f4-432f-419f-8854-69d8bfc135f8¤plot�¨X_apples‘Ù$24d3c1f4-432f-419f-8854-69d8bfc135f8Ù$ba9fa93f-093c-4783-988f-27f4ba228e88„´precedence_heuristic §cell_idÙ$ba9fa93f-093c-4783-988f-27f4ba228e88´downstream_cells_map‚«Î£_computed‘Ù$46d2d5e9-bb6b-409a-acdc-cdffd1a6f797¢Î£�²upstream_cells_map†¦Ï€_hat‘Ù$19360d53-93d8-46fe-82d5-357015e75e22¡+�¢d2‘Ù$cd310392-aabd-40e0-b06f-f8297c7eed6f¢d1‘Ù$10bfb9ea-46a6-4f4d-980e-ed2afce7b39a£cov�¡*�Ù$eac2821e-b25c-4605-857a-cd3bd06303c1„´precedence_heuristic §cell_idÙ$eac2821e-b25c-4605-857a-cd3bd06303c1´downstream_cells_map�¡X‘Ù$24d3c1f4-432f-419f-8854-69d8bfc135f8²upstream_cells_mapНMersenneTwister�¡:�¦Matrix�¨MvNormal�¥undef�¡N‘Ù$876f47d8-b272-4e23-b5ec-5c7d615ff618¡y‘Ù$841ddfc8-85e0-47ee-9288-2d90a84a5dc3¤rand�©Î£_secret‘Ù$3842654e-6dd7-427c-bb77-8b35a2f324fb§Float64�Ù$23c7a54c-d294-11ef-0252-ef7a043e995c„´precedence_heuristic §cell_idÙ$23c7a54c-d294-11ef-0252-ef7a043e995c´downstream_cells_map€²upstream_cells_map‚§@md_str�¨getindex�Ù$841ddfc8-85e0-47ee-9288-2d90a84a5dc3„´precedence_heuristic §cell_idÙ$841ddfc8-85e0-47ee-9288-2d90a84a5dc3´downstream_cells_map�¡y”Ù$fedb7530-6fce-496c-a55a-3e9908f9711aÙ$cc8144d9-9ecf-4cbd-aea9-0c7a2fca2d94Ù$eac2821e-b25c-4605-857a-cd3bd06303c1Ù$24d3c1f4-432f-419f-8854-69d8bfc135f8²upstream_cells_map„¯MersenneTwister�¡N‘Ù$876f47d8-b272-4e23-b5ec-5c7d615ff618®p_apple_secret‘Ù$c91ed138-9885-43ce-a00e-1ba6e996f1aa¤rand�Ù$36e6b874-a1b8-40d7-8762-f0c5f9121e40„´precedence_heuristic §cell_idÙ$36e6b874-a1b8-40d7-8762-f0c5f9121e40´downstream_cells_map€²upstream_cells_map�¥cgrad�©plot_lims‘Ù$ffa01b68-c3ba-4509-8df6-00596974be0f¨scatter!�¦x_test‘Ù$d9efe8bb-c32c-40f4-89d9-8ace7a0665ba¥range�¥plot!�¡:�¬conditionals‘Ù$46d2d5e9-bb6b-409a-acdc-cdffd1a6f797¨contour!�©X_peaches‘Ù$24d3c1f4-432f-419f-8854-69d8bfc135f8£pdf�¤plot�¨X_apples‘Ù$24d3c1f4-432f-419f-8854-69d8bfc135f8Ù$f63b65b9-86c8-420b-b2d5-28268782f155„´precedence_heuristic §cell_idÙ$f63b65b9-86c8-420b-b2d5-28268782f155´downstream_cells_map€²upstream_cells_map‚§@md_str�¨getindex�Ù$ffc80e65-a454-4b45-a9b7-76b01c7e96c0„´precedence_heuristic §cell_idÙ$ffc80e65-a454-4b45-a9b7-76b01c7e96c0´downstream_cells_map€²upstream_cells_map�²exercise_statement�Ù$66172ab6-7df8-4068-a748-b33b3f345d6d„´precedence_heuristic §cell_idÙ$66172ab6-7df8-4068-a748-b33b3f345d6d´downstream_cells_map€²upstream_cells_mapƒ­hide_solution�§@md_str�¨getindex�Ù$3228f074-7c1d-420a-bfb0-c3bd693003ad„´precedence_heuristic §cell_idÙ$3228f074-7c1d-420a-bfb0-c3bd693003ad´downstream_cells_map€²upstream_cells_map‚§@md_str�¨getindex�Ù$23c763ce-d294-11ef-015b-736be1a5e9d6„´precedence_heuristic §cell_idÙ$23c763ce-d294-11ef-015b-736be1a5e9d6´downstream_cells_map€²upstream_cells_map‚§@md_str�¨getindex�Ù$fe9d4fbc-f264-459b-8fbe-26663500f6c5„´precedence_heuristic §cell_idÙ$fe9d4fbc-f264-459b-8fbe-26663500f6c5´downstream_cells_map€²upstream_cells_map‚·PlutoUI.TableOfContents�§PlutoUI�Ù$23c6997e-d294-11ef-09a8-a50563e5975b„´precedence_heuristic §cell_idÙ$23c6997e-d294-11ef-09a8-a50563e5975b´downstream_cells_map€²upstream_cells_map‚§@md_str�¨getindex�Ù$23c7baa4-d294-11ef-22c1-31b0d86f5586„´precedence_heuristic §cell_idÙ$23c7baa4-d294-11ef-22c1-31b0d86f5586´downstream_cells_map€²upstream_cells_mapƒ§@md_str�¨getindex�¤HTML�Ù$5730758d-80cd-4d95-b16c-399c38cf585b„´precedence_heuristic §cell_idÙ$5730758d-80cd-4d95-b16c-399c38cf585b´downstream_cells_map€²upstream_cells_map‚§@md_str�¨getindex�Ù$69732524-90fd-46f4-9706-c07ce6226d2b„´precedence_heuristic §cell_idÙ$69732524-90fd-46f4-9706-c07ce6226d2b´downstream_cells_map€²upstream_cells_mapˆ¥plot!�¡:�©X_peaches‘Ù$24d3c1f4-432f-419f-8854-69d8bfc135f8©plot_lims‘Ù$ffa01b68-c3ba-4509-8df6-00596974be0f§scatter�¨X_apples‘Ù$24d3c1f4-432f-419f-8854-69d8bfc135f8¨scatter!�¦x_test‘Ù$d9efe8bb-c32c-40f4-89d9-8ace7a0665baÙ$c79525b1-7b44-4585-8292-84abe20a1a3d„´precedence_heuristic §cell_idÙ$c79525b1-7b44-4585-8292-84abe20a1a3d´downstream_cells_map€²upstream_cells_map‚§@md_str�¨getindex�Ù$e8cbfc78-04dd-4196-8011-90283969e5b1„´precedence_heuristic §cell_idÙ$e8cbfc78-04dd-4196-8011-90283969e5b1´downstream_cells_map�¬peach_marker“Ù$51a46b5e-0c35-4841-a4f3-413d5d294805Ù$77280f3b-e391-482f-936f-703d1d3c4006Ù$23c82e10-d294-11ef-286a-ff6fee0f2805²upstream_cells_map„°HypertextLiteral�¤@htl�·HypertextLiteral.Result�·HypertextLiteral.Bypass�Ù$e65e0e33-3e4f-4765-84ea-a4fb5d43269e„´precedence_heuristic §cell_idÙ$e65e0e33-3e4f-4765-84ea-a4fb5d43269e´downstream_cells_map€²upstream_cells_map‚§@md_str�¨getindex�Ù$10bfb9ea-46a6-4f4d-980e-ed2afce7b39a„´precedence_heuristic §cell_idÙ$10bfb9ea-46a6-4f4d-980e-ed2afce7b39a´downstream_cells_map�¢d1’Ù$ba9fa93f-093c-4783-988f-27f4ba228e88Ù$46d2d5e9-bb6b-409a-acdc-cdffd1a6f797²upstream_cells_map…¤conj�§fit_mle�¨X_apples‘Ù$24d3c1f4-432f-419f-8854-69d8bfc135f8§adjoint�ªFullNormal�Ù$cff683bf-0488-41d2-9858-cf8776a48992„´precedence_heuristic §cell_idÙ$cff683bf-0488-41d2-9858-cf8776a48992´downstream_cells_map€²upstream_cells_map‚©X_peaches‘Ù$24d3c1f4-432f-419f-8854-69d8bfc135f8¨X_apples‘Ù$24d3c1f4-432f-419f-8854-69d8bfc135f8Ù$23c7ab20-d294-11ef-1926-afae49e79923„´precedence_heuristic §cell_idÙ$23c7ab20-d294-11ef-1926-afae49e79923´downstream_cells_map€²upstream_cells_map‚§@md_str�¨getindex�Ù$24a08e5c-c2c1-4f1f-a2c1-998b30147e61„´precedence_heuristic §cell_idÙ$24a08e5c-c2c1-4f1f-a2c1-998b30147e61´downstream_cells_map€²upstream_cells_map‚§@md_str�¨getindex�Ù$23c85d90-d294-11ef-375e-7101d4d3cbfa„´precedence_heuristic §cell_idÙ$23c85d90-d294-11ef-375e-7101d4d3cbfa´downstream_cells_map€²upstream_cells_map‚§@md_str�¨getindex�Ù$1a890e4b-b8a9-4a6e-b1f3-17863e1416d7„´precedence_heuristic §cell_idÙ$1a890e4b-b8a9-4a6e-b1f3-17863e1416d7´downstream_cells_map€²upstream_cells_map�²challenge_solution�Ù$3842654e-6dd7-427c-bb77-8b35a2f324fb„´precedence_heuristic §cell_idÙ$3842654e-6dd7-427c-bb77-8b35a2f324fb´downstream_cells_map�©Î£_secret‘Ù$eac2821e-b25c-4605-857a-cd3bd06303c1²upstream_cells_map€Ù$e91effb4-b3ac-4d7a-b93f-33a78a125110„´precedence_heuristic §cell_idÙ$e91effb4-b3ac-4d7a-b93f-33a78a125110´downstream_cells_map€²upstream_cells_map‚§@md_str�¨getindex�Ù$a985e1d3-4867-4991-a60e-e85a9730311b„´precedence_heuristic §cell_idÙ$a985e1d3-4867-4991-a60e-e85a9730311b´downstream_cells_map�¬apple_marker•Ù$51a46b5e-0c35-4841-a4f3-413d5d294805Ù$77280f3b-e391-482f-936f-703d1d3c4006Ù$23c82e10-d294-11ef-286a-ff6fee0f2805Ù$90b862a5-d5bc-4122-a942-f01062daa86aÙ$9973e8e5-4744-4ff6-9494-1c93503f11c1²upstream_cells_map„°HypertextLiteral�¤@htl�·HypertextLiteral.Result�·HypertextLiteral.Bypass�Ù$23c7c920-d294-11ef-1b6d-d98dd54dcbe3„´precedence_heuristic §cell_idÙ$23c7c920-d294-11ef-1b6d-d98dd54dcbe3´downstream_cells_map€²upstream_cells_map‚§@md_str�¨getindex�Ù$21602809-d98b-43d7-8c41-80dc8de6da57„´precedence_heuristic §cell_idÙ$21602809-d98b-43d7-8c41-80dc8de6da57´downstream_cells_map€²upstream_cells_map‚§@md_str�¨getindex�Ù$14362031-7977-4a0c-b329-23da9b5b2f62„´precedence_heuristic §cell_idÙ$14362031-7977-4a0c-b329-23da9b5b2f62´downstream_cells_map€²upstream_cells_mapƒ§@md_str�¨getindex�ªkeyconcept�Ù$5092090d-cfac-4ced-b61e-fb7107a4c638„´precedence_heuristic §cell_idÙ$5092090d-cfac-4ced-b61e-fb7107a4c638´downstream_cells_map€²upstream_cells_map‚§@md_str�¨getindex�Ù$23c7f170-d294-11ef-1340-fbdf4ce5fd44„´precedence_heuristic §cell_idÙ$23c7f170-d294-11ef-1340-fbdf4ce5fd44´downstream_cells_map€²upstream_cells_map‚§@md_str�¨getindex�Ù$23c82e10-d294-11ef-286a-ff6fee0f2805„´precedence_heuristic §cell_idÙ$23c82e10-d294-11ef-286a-ff6fee0f2805´downstream_cells_map€²upstream_cells_map„¬apple_marker‘Ù$a985e1d3-4867-4991-a60e-e85a9730311b¬peach_marker‘Ù$e8cbfc78-04dd-4196-8011-90283969e5b1§@md_str�¨getindex�Ù$4481b38d-dc67-4c1f-ac0b-b348f0aea461„´precedence_heuristic §cell_idÙ$4481b38d-dc67-4c1f-ac0b-b348f0aea461´downstream_cells_map€²upstream_cells_map‚§@md_str�¨getindex�Ù$23c7e4a0-d294-11ef-16e9-6f96a41baf97„´precedence_heuristic §cell_idÙ$23c7e4a0-d294-11ef-16e9-6f96a41baf97´downstream_cells_map€²upstream_cells_map‚§@md_str�¨getindex�Ù$cc8144d9-9ecf-4cbd-aea9-0c7a2fca2d94„´precedence_heuristic §cell_idÙ$cc8144d9-9ecf-4cbd-aea9-0c7a2fca2d94´downstream_cells_map�«p_apple_est‘Ù$19360d53-93d8-46fe-82d5-357015e75e22²upstream_cells_map„¡/�¦length�¡y‘Ù$841ddfc8-85e0-47ee-9288-2d90a84a5dc3£sum�Ù$46d2d5e9-bb6b-409a-acdc-cdffd1a6f797„´precedence_heuristic §cell_idÙ$46d2d5e9-bb6b-409a-acdc-cdffd1a6f797´downstream_cells_map�¬conditionals’Ù$36e6b874-a1b8-40d7-8762-f0c5f9121e40Ù$33d5d6e7-1208-4c5b-b651-429b3b6ad50b²upstream_cells_map…«Î£_computed‘Ù$ba9fa93f-093c-4783-988f-27f4ba228e88¤mean�¨MvNormal�¢d1‘Ù$10bfb9ea-46a6-4f4d-980e-ed2afce7b39a¢d2‘Ù$cd310392-aabd-40e0-b06f-f8297c7eed6fÙ$6631c0e4-4941-442e-8dd4-fa307ee7a8c0„´precedence_heuristic§cell_idÙ$6631c0e4-4941-442e-8dd4-fa307ee7a8c0´downstream_cells_map�¦Random�²upstream_cells_map€Ù$358fac57-7458-40b5-9f69-50ad4ca7edde„´precedence_heuristic §cell_idÙ$358fac57-7458-40b5-9f69-50ad4ca7edde´downstream_cells_map€²upstream_cells_map�±keyconceptsummary�Ù$25e18c78-9cac-4faa-bb7c-ac036d0eac90„´precedence_heuristic §cell_idÙ$25e18c78-9cac-4faa-bb7c-ac036d0eac90´downstream_cells_map€²upstream_cells_mapƒ­hide_solution�§@md_str�¨getindex�Ù$a42ec280-a88a-485b-9f34-219b370e5784„´precedence_heuristic §cell_idÙ$a42ec280-a88a-485b-9f34-219b370e5784´downstream_cells_map€²upstream_cells_map�²navigate_prev_next�Ù$ef1e5885-7153-4b55-9f97-1e984c2504e6„´precedence_heuristic §cell_idÙ$ef1e5885-7153-4b55-9f97-1e984c2504e6´downstream_cells_map€²upstream_cells_mapƒ­hide_solution�§@md_str�¨getindex�Ù$23c82154-d294-11ef-0945-c9c94fc2a44d„´precedence_heuristic §cell_idÙ$23c82154-d294-11ef-0945-c9c94fc2a44d´downstream_cells_map€²upstream_cells_map‚§@md_str�¨getindex�Ù$50cbe27e-009f-4df1-b80a-cf1e73fc525e„´precedence_heuristic§cell_idÙ$50cbe27e-009f-4df1-b80a-cf1e73fc525e´downstream_cells_map�¬LaTeXStrings‘Ù$4ada77d1-09f2-49c7-a44f-1928e0dc5421²upstream_cells_map€Ù$bf39f423-7df3-4990-a254-c28a1bdf23bf„´precedence_heuristic §cell_idÙ$bf39f423-7df3-4990-a254-c28a1bdf23bf´downstream_cells_map€²upstream_cells_map�¦x_test‘Ù$d9efe8bb-c32c-40f4-89d9-8ace7a0665baÙ$90b862a5-d5bc-4122-a942-f01062daa86a„´precedence_heuristic §cell_idÙ$90b862a5-d5bc-4122-a942-f01062daa86a´downstream_cells_map€²upstream_cells_mapƒ¬apple_marker‘Ù$a985e1d3-4867-4991-a60e-e85a9730311b§@md_str�¨getindex�Ù$b01a4a56-bed2-4a06-991a-831adc84aa3e„´precedence_heuristic §cell_idÙ$b01a4a56-bed2-4a06-991a-831adc84aa3e´downstream_cells_map€²upstream_cells_mapƒ­hide_solution�§@md_str�¨getindex�Ù$117f3f65-a9bd-4b25-93e2-42ac1e576b6d„´precedence_heuristic §cell_idÙ$117f3f65-a9bd-4b25-93e2-42ac1e576b6d´downstream_cells_map€²upstream_cells_mapƒ§@md_str�¨getindex�ªkeyconcept�Ù$fe324e92-d753-46cd-aad9-794a76dc806b„´precedence_heuristic §cell_idÙ$fe324e92-d753-46cd-aad9-794a76dc806b´downstream_cells_map€²upstream_cells_mapƒ§@md_str�¨getindex�®unknown_marker‘Ù$79fa1b47-460f-457e-aebc-646f60ffecc1Ù$a8adaf31-bee2-40e9-8d9b-bb9f1ad996ca„´precedence_heuristic §cell_idÙ$a8adaf31-bee2-40e9-8d9b-bb9f1ad996ca´downstream_cells_map€²upstream_cells_map‚§@md_str�¨getindex�Ù$7e5213d6-4a68-4843-ab4c-77ea3ed8b0cd„´precedence_heuristic §cell_idÙ$7e5213d6-4a68-4843-ab4c-77ea3ed8b0cd´downstream_cells_map€²upstream_cells_map‚§@md_str�¨getindex�Ù$f1575443-c9fb-4674-bbce-bf3a5a6d5a8d„´precedence_heuristic§cell_idÙ$f1575443-c9fb-4674-bbce-bf3a5a6d5a8d´downstream_cells_map‚­Distributions�¥Plots�²upstream_cells_map€Ù$23c73b54-d294-11ef-0ef8-8d9159139a1b„´precedence_heuristic §cell_idÙ$23c73b54-d294-11ef-0ef8-8d9159139a1b´downstream_cells_map€²upstream_cells_map‚§@md_str�¨getindex�Ù$77280f3b-e391-482f-936f-703d1d3c4006„´precedence_heuristic §cell_idÙ$77280f3b-e391-482f-936f-703d1d3c4006´downstream_cells_map€²upstream_cells_map„¬apple_marker‘Ù$a985e1d3-4867-4991-a60e-e85a9730311b¬peach_marker‘Ù$e8cbfc78-04dd-4196-8011-90283969e5b1§@md_str�¨getindex�Ù$24d3c1f4-432f-419f-8854-69d8bfc135f8„´precedence_heuristic §cell_idÙ$24d3c1f4-432f-419f-8854-69d8bfc135f8´downstream_cells_map‚©X_peaches•Ù$69732524-90fd-46f4-9706-c07ce6226d2bÙ$cff683bf-0488-41d2-9858-cf8776a48992Ù$36e6b874-a1b8-40d7-8762-f0c5f9121e40Ù$cd310392-aabd-40e0-b06f-f8297c7eed6fÙ$4ada77d1-09f2-49c7-a44f-1928e0dc5421¨X_apples•Ù$69732524-90fd-46f4-9706-c07ce6226d2bÙ$cff683bf-0488-41d2-9858-cf8776a48992Ù$36e6b874-a1b8-40d7-8762-f0c5f9121e40Ù$10bfb9ea-46a6-4f4d-980e-ed2afce7b39aÙ$4ada77d1-09f2-49c7-a44f-1928e0dc5421²upstream_cells_mapˆ¤conj�§collect�¡:�§findall�¡X‘Ù$eac2821e-b25c-4605-857a-cd3bd06303c1¡y‘Ù$841ddfc8-85e0-47ee-9288-2d90a84a5dc3§adjoint�¡!�Ù$23c73302-d294-11ef-0c12-571686b202a9„´precedence_heuristic §cell_idÙ$23c73302-d294-11ef-0c12-571686b202a9´downstream_cells_map€²upstream_cells_map‚§@md_str�¨getindex�Ù$fedb7530-6fce-496c-a55a-3e9908f9711a„´precedence_heuristic §cell_idÙ$fedb7530-6fce-496c-a55a-3e9908f9711a´downstream_cells_map€²upstream_cells_map„£Int�¡y‘Ù$841ddfc8-85e0-47ee-9288-2d90a84a5dc3¢|>�¤join�Ù$23c75dc8-d294-11ef-3c57-614e75f06d8f„´precedence_heuristic §cell_idÙ$23c75dc8-d294-11ef-3c57-614e75f06d8f´downstream_cells_map€²upstream_cells_mapƒ§@md_str�¨getindex�¤HTML�Ù$79fa1b47-460f-457e-aebc-646f60ffecc1„´precedence_heuristic §cell_idÙ$79fa1b47-460f-457e-aebc-646f60ffecc1´downstream_cells_map�®unknown_marker‘Ù$fe324e92-d753-46cd-aad9-794a76dc806b²upstream_cells_map„°HypertextLiteral�¤@htl�·HypertextLiteral.Result�·HypertextLiteral.Bypass�Ù$d9efe8bb-c32c-40f4-89d9-8ace7a0665ba„´precedence_heuristic §cell_idÙ$d9efe8bb-c32c-40f4-89d9-8ace7a0665ba´downstream_cells_map�¦x_test•Ù$69732524-90fd-46f4-9706-c07ce6226d2bÙ$bf39f423-7df3-4990-a254-c28a1bdf23bfÙ$36e6b874-a1b8-40d7-8762-f0c5f9121e40Ù$723e09fc-ec63-4c47-844c-d821515ce0f4Ù$4ada77d1-09f2-49c7-a44f-1928e0dc5421²upstream_cells_map€Ù$23c74748-d294-11ef-2170-bf45b6379e4d„´precedence_heuristic §cell_idÙ$23c74748-d294-11ef-2170-bf45b6379e4d´downstream_cells_map€²upstream_cells_map‚§@md_str�¨getindex�Ù$9973e8e5-4744-4ff6-9494-1c93503f11c1„´precedence_heuristic §cell_idÙ$9973e8e5-4744-4ff6-9494-1c93503f11c1´downstream_cells_map€²upstream_cells_mapƒ¬apple_marker‘Ù$a985e1d3-4867-4991-a60e-e85a9730311b§@md_str�¨getindex�Ù$723e09fc-ec63-4c47-844c-d821515ce0f4„´precedence_heuristic §cell_idÙ$723e09fc-ec63-4c47-844c-d821515ce0f4´downstream_cells_map�«#461#result�²upstream_cells_mapаHypertextLiteral�¸HypertextLiteral.content�¯MarkdownLiteral�·HypertextLiteral.Result�¥round�­predict_class‘Ù$33d5d6e7-1208-4c5b-b651-429b3b6ad50bÙ MarkdownLiteral.CMParsedRenderer�¤@mdx‘Ù$26853cdc-0644-4f44-b6db-b5624a4a8689¦x_test‘Ù$d9efe8bb-c32c-40f4-89d9-8ace7a0665ba·HypertextLiteral.Bypass�Ù$876f47d8-b272-4e23-b5ec-5c7d615ff618„´precedence_heuristic §cell_idÙ$876f47d8-b272-4e23-b5ec-5c7d615ff618´downstream_cells_mapƒ©#436#bond�¡N’Ù$841ddfc8-85e0-47ee-9288-2d90a84a5dc3Ù$eac2821e-b25c-4605-857a-cd3bd06303c1¦N_bond’Ù$689ea1f9-0a72-478e-b8a9-ebf450ce95efÙ$845f19c4-c3c5-4368-a48a-a7b57687ddf9²upstream_cells_map‹°HypertextLiteral�¸HypertextLiteral.content�«PlutoRunner�»PlutoRunner.Core.applicable�©@bindname�·HypertextLiteral.Result�¡:�Ù#PlutoRunner.PlutoRunner.create_bond�·HypertextLiteral.Bypass�¦Slider�´PlutoRunner.Base.get�Ù$f7a19975-a919-4659-9b6a-d8963a1cd6d9„´precedence_heuristic §cell_idÙ$f7a19975-a919-4659-9b6a-d8963a1cd6d9´downstream_cells_map€²upstream_cells_map�³challenge_statement�Ù$23c78d3e-d294-11ef-0309-ff10f58f0252„´precedence_heuristic §cell_idÙ$23c78d3e-d294-11ef-0309-ff10f58f0252´downstream_cells_map€²upstream_cells_map‚§@md_str�¨getindex�Ù$689ea1f9-0a72-478e-b8a9-ebf450ce95ef„´precedence_heuristic §cell_idÙ$689ea1f9-0a72-478e-b8a9-ebf450ce95ef´downstream_cells_map€²upstream_cells_map�¦N_bond‘Ù$876f47d8-b272-4e23-b5ec-5c7d615ff618Ù$5c746070-19a9-464b-aedc-401d016dfdb6„´precedence_heuristic §cell_idÙ$5c746070-19a9-464b-aedc-401d016dfdb6´downstream_cells_map€²upstream_cells_map�²exercise_statement�Ù$2f2cb20f-ff7c-4b7f-8aa0-f5b3addb9299„´precedence_heuristic §cell_idÙ$2f2cb20f-ff7c-4b7f-8aa0-f5b3addb9299´downstream_cells_map€²upstream_cells_map�¬NotebookCard�Ù$2e1ccf78-6097-4097-8bc8-1f1ec2d9c3ff„´precedence_heuristic §cell_idÙ$2e1ccf78-6097-4097-8bc8-1f1ec2d9c3ff´downstream_cells_map€²upstream_cells_map‚§@md_str�¨getindex�Ù$84353cd1-e4fb-4689-9e90-d8995cbe2e9b„´precedence_heuristic §cell_idÙ$84353cd1-e4fb-4689-9e90-d8995cbe2e9b´downstream_cells_map€²upstream_cells_mapƒ§@md_str�¨getindex�§details�Ù$51a46b5e-0c35-4841-a4f3-413d5d294805„´precedence_heuristic §cell_idÙ$51a46b5e-0c35-4841-a4f3-413d5d294805´downstream_cells_map€²upstream_cells_map„¬apple_marker‘Ù$a985e1d3-4867-4991-a60e-e85a9730311b¬peach_marker‘Ù$e8cbfc78-04dd-4196-8011-90283969e5b1§@md_str�¨getindex�Ù$32cb67f6-1ed2-4d30-8493-e4eed9651526„´precedence_heuristic §cell_idÙ$32cb67f6-1ed2-4d30-8493-e4eed9651526´downstream_cells_map€²upstream_cells_mapƒ­hide_solution�§@md_str�¨getindex�Ù$26853cdc-0644-4f44-b6db-b5624a4a8689„´precedence_heuristic§cell_idÙ$26853cdc-0644-4f44-b6db-b5624a4a8689´downstream_cells_map�¤@mdx‘Ù$723e09fc-ec63-4c47-844c-d821515ce0f4²upstream_cells_map€Ù$cd310392-aabd-40e0-b06f-f8297c7eed6f„´precedence_heuristic §cell_idÙ$cd310392-aabd-40e0-b06f-f8297c7eed6f´downstream_cells_map�¢d2’Ù$ba9fa93f-093c-4783-988f-27f4ba228e88Ù$46d2d5e9-bb6b-409a-acdc-cdffd1a6f797²upstream_cells_map…¤conj�§fit_mle�©X_peaches‘Ù$24d3c1f4-432f-419f-8854-69d8bfc135f8§adjoint�ªFullNormal�Ù$a4463d74-04ea-428a-b5a5-504d96432a0a„´precedence_heuristic §cell_idÙ$a4463d74-04ea-428a-b5a5-504d96432a0a´downstream_cells_map€²upstream_cells_map‚§@md_str�¨getindex�Ù$45f1f80d-18fc-465c-aaf3-54bbcd8bc95e„´precedence_heuristic §cell_idÙ$45f1f80d-18fc-465c-aaf3-54bbcd8bc95e´downstream_cells_map€²upstream_cells_map‚§@md_str�¨getindex�®last_save_timeËAÚ¹&›#;y«notebook_idÙ$28b9672a-d465-11f1-9e83-cd806882963e«in_temp_dir¨metadata�«frontmatterƒ«descriptionÙYCan you teach a computer to tell apples from peaches? Discover generative classification!¥image½https://imgur.com/TGISnuj.png¦author‘‚¤name¥BMLIP£url¸https://github.com/bmlip¥bonds€´cell_execution_orderÜ]Ù$f1a40378-a27c-4aa0-a62c-600ffde0032fÙ$6631c0e4-4941-442e-8dd4-fa307ee7a8c0Ù$f1575443-c9fb-4674-bbce-bf3a5a6d5a8dÙ$26853cdc-0644-4f44-b6db-b5624a4a8689Ù$50cbe27e-009f-4df1-b80a-cf1e73fc525eÙ$23c689fc-d294-11ef-086e-47c4f871bed2Ù$fe9d4fbc-f264-459b-8fbe-26663500f6c5Ù$23c6997e-d294-11ef-09a8-a50563e5975bÙ$f7a19975-a919-4659-9b6a-d8963a1cd6d9Ù$876f47d8-b272-4e23-b5ec-5c7d615ff618Ù$f63b65b9-86c8-420b-b2d5-28268782f155Ù$70a620bc-47c7-46c4-870b-22b3e05039a1Ù$5730758d-80cd-4d95-b16c-399c38cf585bÙ$23c73302-d294-11ef-0c12-571686b202a9Ù$23c73b54-d294-11ef-0ef8-8d9159139a1bÙ$0d52466f-b092-4569-8c2d-b43c725887aeÙ$23c74748-d294-11ef-2170-bf45b6379e4dÙ$23c75dc8-d294-11ef-3c57-614e75f06d8fÙ$23c763ce-d294-11ef-015b-736be1a5e9d6Ù$20cd1582-d7f7-448c-8685-607f7cc1dc9cÙ$23c7779a-d294-11ef-2e2c-6ba6cadb1381Ù$ffc80e65-a454-4b45-a9b7-76b01c7e96c0Ù$2e1ccf78-6097-4097-8bc8-1f1ec2d9c3ffÙ$32cb67f6-1ed2-4d30-8493-e4eed9651526Ù$23c78d3e-d294-11ef-0309-ff10f58f0252Ù$23c798ce-d294-11ef-0190-f342f30e2266Ù$23c7a54c-d294-11ef-0252-ef7a043e995cÙ$23c7ab20-d294-11ef-1926-afae49e79923Ù$14362031-7977-4a0c-b329-23da9b5b2f62Ù$23c7baa4-d294-11ef-22c1-31b0d86f5586Ù$84353cd1-e4fb-4689-9e90-d8995cbe2e9bÙ$23c7c920-d294-11ef-1b6d-d98dd54dcbe3Ù$2f2cb20f-ff7c-4b7f-8aa0-f5b3addb9299Ù$866d8e7a-2b33-4635-84c0-6cbf900b523bÙ$23c82154-d294-11ef-0945-c9c94fc2a44dÙ$23c7e4a0-d294-11ef-16e9-6f96a41baf97Ù$23c7f170-d294-11ef-1340-fbdf4ce5fd44Ù$5c746070-19a9-464b-aedc-401d016dfdb6Ù$8d78f9d3-7ba8-46b0-8d6f-231e681caa49Ù$25e18c78-9cac-4faa-bb7c-ac036d0eac90Ù$117f3f65-a9bd-4b25-93e2-42ac1e576b6dÙ$a8adaf31-bee2-40e9-8d9b-bb9f1ad996caÙ$b01a4a56-bed2-4a06-991a-831adc84aa3eÙ$1a890e4b-b8a9-4a6e-b1f3-17863e1416d7Ù$689ea1f9-0a72-478e-b8a9-ebf450ce95efÙ$4481b38d-dc67-4c1f-ac0b-b348f0aea461Ù$5092090d-cfac-4ced-b61e-fb7107a4c638Ù$3228f074-7c1d-420a-bfb0-c3bd693003adÙ$e91effb4-b3ac-4d7a-b93f-33a78a125110Ù$845f19c4-c3c5-4368-a48a-a7b57687ddf9Ù$21602809-d98b-43d7-8c41-80dc8de6da57Ù$23c85d90-d294-11ef-375e-7101d4d3cbfaÙ$45f1f80d-18fc-465c-aaf3-54bbcd8bc95eÙ$358fac57-7458-40b5-9f69-50ad4ca7eddeÙ$ca11db2d-aa15-4bf1-b949-529c7487d11dÙ$24a08e5c-c2c1-4f1f-a2c1-998b30147e61Ù$66172ab6-7df8-4068-a748-b33b3f345d6dÙ$7e5213d6-4a68-4843-ab4c-77ea3ed8b0cdÙ$ef1e5885-7153-4b55-9f97-1e984c2504e6Ù$a42ec280-a88a-485b-9f34-219b370e5784Ù$e65e0e33-3e4f-4765-84ea-a4fb5d43269eÙ$a4463d74-04ea-428a-b5a5-504d96432a0aÙ$3842654e-6dd7-427c-bb77-8b35a2f324fbÙ$c91ed138-9885-43ce-a00e-1ba6e996f1aaÙ$841ddfc8-85e0-47ee-9288-2d90a84a5dc3Ù$fedb7530-6fce-496c-a55a-3e9908f9711aÙ$cc8144d9-9ecf-4cbd-aea9-0c7a2fca2d94Ù$19360d53-93d8-46fe-82d5-357015e75e22Ù$eac2821e-b25c-4605-857a-cd3bd06303c1Ù$24d3c1f4-432f-419f-8854-69d8bfc135f8Ù$cff683bf-0488-41d2-9858-cf8776a48992Ù$10bfb9ea-46a6-4f4d-980e-ed2afce7b39aÙ$cd310392-aabd-40e0-b06f-f8297c7eed6fÙ$ba9fa93f-093c-4783-988f-27f4ba228e88Ù$46d2d5e9-bb6b-409a-acdc-cdffd1a6f797Ù$33d5d6e7-1208-4c5b-b651-429b3b6ad50bÙ$d9efe8bb-c32c-40f4-89d9-8ace7a0665baÙ$bf39f423-7df3-4990-a254-c28a1bdf23bfÙ$723e09fc-ec63-4c47-844c-d821515ce0f4Ù$ffa01b68-c3ba-4509-8df6-00596974be0fÙ$69732524-90fd-46f4-9706-c07ce6226d2bÙ$36e6b874-a1b8-40d7-8762-f0c5f9121e40Ù$4ada77d1-09f2-49c7-a44f-1928e0dc5421Ù$c79525b1-7b44-4585-8292-84abe20a1a3dÙ$79fa1b47-460f-457e-aebc-646f60ffecc1Ù$fe324e92-d753-46cd-aad9-794a76dc806bÙ$a985e1d3-4867-4991-a60e-e85a9730311bÙ$90b862a5-d5bc-4122-a942-f01062daa86aÙ$9973e8e5-4744-4ff6-9494-1c93503f11c1Ù$e8cbfc78-04dd-4196-8011-90283969e5b1Ù$51a46b5e-0c35-4841-a4f3-413d5d294805Ù$77280f3b-e391-482f-936f-703d1d3c4006Ù$23c82e10-d294-11ef-286a-ff6fee0f2805®process_status¥readyªcell_orderÜ]Ù$23c689fc-d294-11ef-086e-47c4f871bed2Ù$fe9d4fbc-f264-459b-8fbe-26663500f6c5Ù$23c6997e-d294-11ef-09a8-a50563e5975bÙ$f7a19975-a919-4659-9b6a-d8963a1cd6d9Ù$51a46b5e-0c35-4841-a4f3-413d5d294805Ù$876f47d8-b272-4e23-b5ec-5c7d615ff618Ù$69732524-90fd-46f4-9706-c07ce6226d2bÙ$f63b65b9-86c8-420b-b2d5-28268782f155Ù$841ddfc8-85e0-47ee-9288-2d90a84a5dc3Ù$fedb7530-6fce-496c-a55a-3e9908f9711aÙ$70a620bc-47c7-46c4-870b-22b3e05039a1Ù$cff683bf-0488-41d2-9858-cf8776a48992Ù$fe324e92-d753-46cd-aad9-794a76dc806bÙ$bf39f423-7df3-4990-a254-c28a1bdf23bfÙ$77280f3b-e391-482f-936f-703d1d3c4006Ù$5730758d-80cd-4d95-b16c-399c38cf585bÙ$23c73302-d294-11ef-0c12-571686b202a9Ù$23c73b54-d294-11ef-0ef8-8d9159139a1bÙ$0d52466f-b092-4569-8c2d-b43c725887aeÙ$23c74748-d294-11ef-2170-bf45b6379e4dÙ$23c75dc8-d294-11ef-3c57-614e75f06d8fÙ$23c763ce-d294-11ef-015b-736be1a5e9d6Ù$20cd1582-d7f7-448c-8685-607f7cc1dc9cÙ$23c7779a-d294-11ef-2e2c-6ba6cadb1381Ù$ffc80e65-a454-4b45-a9b7-76b01c7e96c0Ù$2e1ccf78-6097-4097-8bc8-1f1ec2d9c3ffÙ$32cb67f6-1ed2-4d30-8493-e4eed9651526Ù$23c78d3e-d294-11ef-0309-ff10f58f0252Ù$23c798ce-d294-11ef-0190-f342f30e2266Ù$23c7a54c-d294-11ef-0252-ef7a043e995cÙ$23c7ab20-d294-11ef-1926-afae49e79923Ù$14362031-7977-4a0c-b329-23da9b5b2f62Ù$23c7baa4-d294-11ef-22c1-31b0d86f5586Ù$84353cd1-e4fb-4689-9e90-d8995cbe2e9bÙ$23c7c920-d294-11ef-1b6d-d98dd54dcbe3Ù$2f2cb20f-ff7c-4b7f-8aa0-f5b3addb9299Ù$866d8e7a-2b33-4635-84c0-6cbf900b523bÙ$23c82154-d294-11ef-0945-c9c94fc2a44dÙ$23c7e4a0-d294-11ef-16e9-6f96a41baf97Ù$23c7f170-d294-11ef-1340-fbdf4ce5fd44Ù$5c746070-19a9-464b-aedc-401d016dfdb6Ù$8d78f9d3-7ba8-46b0-8d6f-231e681caa49Ù$25e18c78-9cac-4faa-bb7c-ac036d0eac90Ù$117f3f65-a9bd-4b25-93e2-42ac1e576b6dÙ$a8adaf31-bee2-40e9-8d9b-bb9f1ad996caÙ$b01a4a56-bed2-4a06-991a-831adc84aa3eÙ$1a890e4b-b8a9-4a6e-b1f3-17863e1416d7Ù$23c82e10-d294-11ef-286a-ff6fee0f2805Ù$36e6b874-a1b8-40d7-8762-f0c5f9121e40Ù$689ea1f9-0a72-478e-b8a9-ebf450ce95efÙ$4481b38d-dc67-4c1f-ac0b-b348f0aea461Ù$cc8144d9-9ecf-4cbd-aea9-0c7a2fca2d94Ù$19360d53-93d8-46fe-82d5-357015e75e22Ù$5092090d-cfac-4ced-b61e-fb7107a4c638Ù$10bfb9ea-46a6-4f4d-980e-ed2afce7b39aÙ$cd310392-aabd-40e0-b06f-f8297c7eed6fÙ$3228f074-7c1d-420a-bfb0-c3bd693003adÙ$ba9fa93f-093c-4783-988f-27f4ba228e88Ù$46d2d5e9-bb6b-409a-acdc-cdffd1a6f797Ù$e91effb4-b3ac-4d7a-b93f-33a78a125110Ù$90b862a5-d5bc-4122-a942-f01062daa86aÙ$33d5d6e7-1208-4c5b-b651-429b3b6ad50bÙ$723e09fc-ec63-4c47-844c-d821515ce0f4Ù$9973e8e5-4744-4ff6-9494-1c93503f11c1Ù$4ada77d1-09f2-49c7-a44f-1928e0dc5421Ù$845f19c4-c3c5-4368-a48a-a7b57687ddf9Ù$21602809-d98b-43d7-8c41-80dc8de6da57Ù$23c85d90-d294-11ef-375e-7101d4d3cbfaÙ$45f1f80d-18fc-465c-aaf3-54bbcd8bc95eÙ$358fac57-7458-40b5-9f69-50ad4ca7eddeÙ$ca11db2d-aa15-4bf1-b949-529c7487d11dÙ$24a08e5c-c2c1-4f1f-a2c1-998b30147e61Ù$66172ab6-7df8-4068-a748-b33b3f345d6dÙ$7e5213d6-4a68-4843-ab4c-77ea3ed8b0cdÙ$ef1e5885-7153-4b55-9f97-1e984c2504e6Ù$a42ec280-a88a-485b-9f34-219b370e5784Ù$e65e0e33-3e4f-4765-84ea-a4fb5d43269eÙ$f1a40378-a27c-4aa0-a62c-600ffde0032fÙ$6631c0e4-4941-442e-8dd4-fa307ee7a8c0Ù$f1575443-c9fb-4674-bbce-bf3a5a6d5a8dÙ$26853cdc-0644-4f44-b6db-b5624a4a8689Ù$50cbe27e-009f-4df1-b80a-cf1e73fc525eÙ$a4463d74-04ea-428a-b5a5-504d96432a0aÙ$3842654e-6dd7-427c-bb77-8b35a2f324fbÙ$c91ed138-9885-43ce-a00e-1ba6e996f1aaÙ$eac2821e-b25c-4605-857a-cd3bd06303c1Ù$24d3c1f4-432f-419f-8854-69d8bfc135f8Ù$d9efe8bb-c32c-40f4-89d9-8ace7a0665baÙ$ffa01b68-c3ba-4509-8df6-00596974be0fÙ$c79525b1-7b44-4585-8292-84abe20a1a3dÙ$79fa1b47-460f-457e-aebc-646f60ffecc1Ù$a985e1d3-4867-4991-a60e-e85a9730311bÙ$e8cbfc78-04dd-4196-8011-90283969e5b1«cell_inputsÞ]Ù$0d52466f-b092-4569-8c2d-b43c725887ae„¨metadataƒ¨disabled©show_logsîskip_as_script§cell_idÙ$0d52466f-b092-4569-8c2d-b43c725887ae«code_foldedäcodeÚ;md""" #### Likelihood Assume a Gaussian **class-conditional data-generating distribution** with **equal covariance matrix** across the classes, ```math p(x_n|\mathcal{C}_{k}) = \mathcal{N}(x_n|\mu_k,\Sigma) \tag{1} ``` with notational shorthand: ``\mathcal{C}_{k} \triangleq (y_n \in \mathcal{C}_{k})``. """Ù$23c689fc-d294-11ef-086e-47c4f871bed2„¨metadataƒ¨disabled©show_logsîskip_as_script§cell_idÙ$23c689fc-d294-11ef-086e-47c4f871bed2«code_foldedäcodeÙ"title("Generative Classification")Ù$23c7779a-d294-11ef-2e2c-6ba6cadb1381„¨metadataƒ¨disabled©show_logsîskip_as_script§cell_idÙ$23c7779a-d294-11ef-2e2c-6ba6cadb1381«code_foldedäcodeÚÇmd""" ## Parameter Estimation In principle, a full Bayesian treatment requires us to specify prior distributions over the model parameters ``\theta = \{ \{\pi_k\}, \{\mu_k\}, \Sigma \}``, and then apply Bayes rule to obtain the corresponding posterior distributions. While this is certainly possible, the mathematics quickly becomes bewildering. Therefore, we opt for maximum likelihood estimation of the parameters as a more practical alternative. """Ù$f1a40378-a27c-4aa0-a62c-600ffde0032f„¨metadataƒ¨disabled©show_logsîskip_as_script§cell_idÙ$f1a40378-a27c-4aa0-a62c-600ffde0032f«code_folded¤code¸using BmlipTeachingToolsÙ$8d78f9d3-7ba8-46b0-8d6f-231e681caa49„¨metadataƒ¨disabled©show_logsîskip_as_script§cell_idÙ$8d78f9d3-7ba8-46b0-8d6f-231e681caa49«code_foldedäcodeÙ‡md""" Show that the discrimination boundaries for the posterior class probabilities in Eq. (4) evaluates to a line (or hyperplane). """Ù$70a620bc-47c7-46c4-870b-22b3e05039a1„¨metadataƒ¨disabled©show_logsîskip_as_script§cell_idÙ$70a620bc-47c7-46c4-870b-22b3e05039a1«code_foldedäcodeÙTmd""" The features are stored in two matrices, corresponding to the two classes: """Ù$ffa01b68-c3ba-4509-8df6-00596974be0f„¨metadataƒ¨disabled©show_logsîskip_as_script§cell_idÙ$ffa01b68-c3ba-4509-8df6-00596974be0f«code_folded¤codeÙ8const plot_lims = ( xlim=(-.3, 3.1), ylim=(-.4, 4.1), )Ù$866d8e7a-2b33-4635-84c0-6cbf900b523b„¨metadataƒ¨disabled©show_logsîskip_as_script§cell_idÙ$866d8e7a-2b33-4635-84c0-6cbf900b523b«code_foldedäcodeÚ2keyconcept("", md"""For the GCM with equal covariances, the posterior class probability is a softmax function, ```math p(\mathcal{C}_k|x,\theta ) \propto \exp\{\beta_k^T x + \gamma_k\} ``` where ``\beta _k= \Sigma^{-1} \mu_k`` and ``\gamma_k=- \frac{1}{2} \mu_k^T \Sigma^{-1} \mu_k + \log \pi_k``. """)Ù$ca11db2d-aa15-4bf1-b949-529c7487d11d„¨metadataƒ¨disabled©show_logsîskip_as_script§cell_idÙ$ca11db2d-aa15-4bf1-b949-529c7487d11d«code_foldedäcode¹exercises(header_level=1)Ù$845f19c4-c3c5-4368-a48a-a7b57687ddf9„¨metadataƒ¨disabled©show_logsîskip_as_script§cell_idÙ$845f19c4-c3c5-4368-a48a-a7b57687ddf9«code_foldedäcode¦N_bondÙ$20cd1582-d7f7-448c-8685-607f7cc1dc9c„¨metadataƒ¨disabled©show_logsîskip_as_script§cell_idÙ$20cd1582-d7f7-448c-8685-607f7cc1dc9c«code_foldedäcodeÚIkeyconcept("",md""" A common generative model for classification is the **Gaussian–Categorical model**: ```math p(x_n,\mathcal{C}_k|\,\theta) = \pi_k \cdot \mathcal{N}(x_n|\mu_k,\Sigma) \,, ``` leading to ```math p(x_n,y_n|\,\theta) = \prod_{k=1}^K \big( \pi_k \cdot \mathcal{N}(x|\mu_k,\Sigma)\big)^{y_{nk}} ``` """)Ù$19360d53-93d8-46fe-82d5-357015e75e22„¨metadataƒ¨disabled©show_logsîskip_as_script§cell_idÙ$19360d53-93d8-46fe-82d5-357015e75e22«code_folded¤codeÙ%Ï€_hat = [p_apple_est; 1-p_apple_est]Ù$33d5d6e7-1208-4c5b-b651-429b3b6ad50b„¨metadataƒ¨disabled©show_logsîskip_as_script§cell_idÙ$33d5d6e7-1208-4c5b-b651-429b3b6ad50b«code_folded¤codeÙï# calculate p(C_k | point) function predict_class(k::Int64, point::Vector{<:Real})::Real norm = Ï€_hat[1]*pdf(conditionals[1],point) + Ï€_hat[2]*pdf(conditionals[2],point) return Ï€_hat[k]*pdf(conditionals[k], point) ./ norm endÙ$23c798ce-d294-11ef-0190-f342f30e2266„¨metadataƒ¨disabled©show_logsîskip_as_script§cell_idÙ$23c798ce-d294-11ef-0190-f342f30e2266«code_foldedäcodeÙ�md""" The ML for multinomial class prior (we've done this before!) ```math \begin{align*} \hat \pi_k = \frac{m_k}{N} \end{align*} ``` """Ù$c91ed138-9885-43ce-a00e-1ba6e996f1aa„¨metadataƒ¨disabled©show_logsîskip_as_script§cell_idÙ$c91ed138-9885-43ce-a00e-1ba6e996f1aa«code_folded¤codeÙ&const p_apple_secret = Bernoulli(0.7);Ù$4ada77d1-09f2-49c7-a44f-1928e0dc5421„¨metadataƒ¨disabled©show_logsîskip_as_script§cell_idÙ$4ada77d1-09f2-49c7-a44f-1928e0dc5421«code_foldedäcodeÚlet plot(; plot_lims..., legend=:topleft, title=L"p(apple | x)") scatter!(X_apples[:,1], X_apples[:,2], label="apple", marker=:x, markerstrokewidth=3) scatter!(X_peaches[:,1], X_peaches[:,2], label="peach", marker=:+, markerstrokewidth=3) scatter!([x_test[1]], [x_test[2]], label="unknown", color="yellow") # 'new' unlabelled data point x = range(plot_lims.xlim..., length=60) y = range(plot_lims.ylim..., length=60) heatmap!(x, y, (x, y) -> predict_class(1, [x,y]); opacity=.4, color=cgrad(:bluesreds, rev=true)) plot!() endÙ$ba9fa93f-093c-4783-988f-27f4ba228e88„¨metadataƒ¨disabled©show_logsîskip_as_script§cell_idÙ$ba9fa93f-093c-4783-988f-27f4ba228e88«code_folded¤codeÙZΣ_computed = Σ = Ï€_hat[1]*cov(d1) + Ï€_hat[2]*cov(d2) # Combine Σâ‚� and Σ₂ into ΣÙ$eac2821e-b25c-4605-857a-cd3bd06303c1„¨metadataƒ¨disabled©show_logsîskip_as_script§cell_idÙ$eac2821e-b25c-4605-857a-cd3bd06303c1«code_folded¤codeÚIX = let Σ = Σ_secret p_given_apple = MvNormal([1.0, 1.0], Σ) # p(X|y=apple) p_given_peach = MvNormal([1.7, 2.5], Σ) # p(X|y=peach) # Apple or peach? X = Matrix{Float64}(undef,2,N); rng = MersenneTwister(76) for n in 1:N X[:,n] = rand(rng, y[n] ? p_given_apple : p_given_peach) end # for X end;Ù$23c7a54c-d294-11ef-0252-ef7a043e995c„¨metadataƒ¨disabled©show_logsîskip_as_script§cell_idÙ$23c7a54c-d294-11ef-0252-ef7a043e995c«code_foldedäcodeÚÖmd""" Now group the data into separate classes and do MVG ML estimation for class-conditional parameters (we've done this before as well): ```math \begin{align*} \hat \mu_k &= \frac{ \sum_n y_{nk} x_n} { \sum_n y_{nk} } = \frac{1}{m_k} \sum_n y_{nk} x_n \\ \hat \Sigma &= \frac{1}{N} \sum_{n,k} y_{nk} (x_n-\hat \mu_k)(x_n-\hat \mu_k)^T \\ &= \sum_k \hat \pi_k \cdot \underbrace{ \left( \frac{1}{m_k} \sum_{n} y_{nk} (x_n-\hat \mu_k)(x_n-\hat \mu_k)^T \right) }_{ \text{class-cond. variance} } \\ &= \sum_k \hat \pi_k \cdot \hat \Sigma_k \end{align*} ``` where ``\hat \pi_k``, ``\hat{\mu}_k`` and ``\hat{\Sigma}_k`` are the sample proportion, sample mean and sample variance for the ``k``th class, respectively. """Ù$841ddfc8-85e0-47ee-9288-2d90a84a5dc3„¨metadataƒ¨disabled©show_logsîskip_as_script§cell_idÙ$841ddfc8-85e0-47ee-9288-2d90a84a5dc3«code_folded¤codeÙ0y = rand(MersenneTwister(23), p_apple_secret, N)Ù$36e6b874-a1b8-40d7-8762-f0c5f9121e40„¨metadataƒ¨disabled©show_logsîskip_as_script§cell_idÙ$36e6b874-a1b8-40d7-8762-f0c5f9121e40«code_foldedäcodeÚïlet plot(; plot_lims..., legend=:topleft) scatter!(X_apples[:,1], X_apples[:,2], label="apple", marker=:x, markerstrokewidth=3) scatter!(X_peaches[:,1], X_peaches[:,2], label="peach", marker=:+, markerstrokewidth=3) scatter!([x_test[1]], [x_test[2]], label="unknown", color="yellow") # 'new' unlabelled data point x = y = range(-1, stop = 5, length = 40) for distr in conditionals contour!(x, y, (x, y) -> pdf(distr, [x,y]); opacity=.4, color=cgrad(:grays, rev=true)) end plot!() endÙ$f63b65b9-86c8-420b-b2d5-28268782f155„¨metadataƒ¨disabled©show_logsîskip_as_script§cell_idÙ$f63b65b9-86c8-420b-b2d5-28268782f155«code_foldedäcodeÙÀmd""" In the scatter plot, the two features are represented along the two ``x``-coordinates, while the fruit label ``y \in \{\text{apple}, \text{peach}\}`` is encoded by the marker style. """Ù$ffc80e65-a454-4b45-a9b7-76b01c7e96c0„¨metadataƒ¨disabled©show_logsîskip_as_script§cell_idÙ$ffc80e65-a454-4b45-a9b7-76b01c7e96c0«code_foldedäcodeÙPexercise_statement("Evaluate log-likelihood" , color= "yellow", header_level=4 )Ù$66172ab6-7df8-4068-a748-b33b3f345d6d„¨metadataƒ¨disabled©show_logsîskip_as_script§cell_idÙ$66172ab6-7df8-4068-a748-b33b3f345d6d«code_foldedäcodeÚjhide_solution( md""" - (a) We choose ``C_1`` if ``p(C_1|x)/p(C_2|x) > 1``. This condition can be worked out as ```math \frac{p(C_1|x)}{p(C_2|x)} = \frac{p(x|C_1)p(C_1)}{p(x|C_2)p(C_2)} = \frac{10 \times 0.6}{200(x-1)\times 0.4}>1 ``` which evaluates to choosing ```math \mathrm{Decision} = \begin{cases} C_1 & \text{ if $1.0\leq x < 1.075$} \\ C_2 & \text{ if $1.075 \leq x \leq 1.1$ } \end{cases} ``` The probability that ``x`` falls outside the interval ``[1.0,1.1]`` is zero. - (b) The total probability of error is ```math p(\text{error})=\int_x p(\text{error}|x)p(x) \mathrm{d}{x} \,. ``` We can work this out as ```math \begin{align*} p(\text{error}) &= \int_x p(\text{error}|x)p(x)\mathrm{d}{x}\\ &= \int_{1.0}^{1.075} p(C_2|x)p(x) \mathrm{d}{x} + \int_{1.075}^{1.1} p(C_1|x)p(x) \mathrm{d}{x}\\ &= \int_{1.0}^{1.075} p(x|C_2)p(C_2) \mathrm{d}{x} + \int_{1.075}^{1.1} p(x|C_1)p(C_1) \mathrm{d}{x}\\ &= \int_{1.0}^{1.075}0.4\cdot 200(x-1) \mathrm{d}{x} + \int_{1.075}^{1.1} 0.6\cdot 10 \mathrm{d}{x}\\ &=80\cdot[x^2/2-x]_{1.0}^{1.075} + 6\cdot[x]_{1.075}^{1.1}\\ &=0.225 + 0.15\\ &=0.375 \end{align*} ``` """)Ù$3228f074-7c1d-420a-bfb0-c3bd693003ad„¨metadataƒ¨disabled©show_logsîskip_as_script§cell_idÙ$3228f074-7c1d-420a-bfb0-c3bd693003ad«code_foldedäcodeÙ—md""" Our model assumes that both distributions have the same covariance matrix. We get this in practice by taking the weighted average of the two: """Ù$23c763ce-d294-11ef-015b-736be1a5e9d6„¨metadataƒ¨disabled©show_logsîskip_as_script§cell_idÙ$23c763ce-d294-11ef-015b-736be1a5e9d6«code_foldedäcodeÙ md""" As usual, once the model has been specified, the rest (inference for parameters and application) can be executed through straight probability theory. """Ù$fe9d4fbc-f264-459b-8fbe-26663500f6c5„¨metadataƒ¨disabled©show_logsîskip_as_script§cell_idÙ$fe9d4fbc-f264-459b-8fbe-26663500f6c5«code_foldedäcode¹PlutoUI.TableOfContents()Ù$23c6997e-d294-11ef-09a8-a50563e5975b„¨metadataƒ¨disabled©show_logsîskip_as_script§cell_idÙ$23c6997e-d294-11ef-09a8-a50563e5975b«code_foldedäcodeÚmd""" ## Preliminaries ##### Goal * Introduction to linear generative classification with a Gaussian-categorical generative model ##### Materials * Mandatory * These lecture notes * Optional * [Bishop PRML book](https://www.microsoft.com/en-us/research/wp-content/uploads/2006/01/Bishop-Pattern-Recognition-and-Machine-Learning-2006.pdf) (2006), pp. 196-202 (section 4.2 focuses on binary classification, whereas in these lecture notes we describe generative classification for multiple classes). """Ù$23c7baa4-d294-11ef-22c1-31b0d86f5586„¨metadataƒ¨disabled©show_logsîskip_as_script§cell_idÙ$23c7baa4-d294-11ef-22c1-31b0d86f5586«code_foldedäcodeÚ:md""" ## Application: Class prediction for new Data ##### the posterior class probability Let's apply the trained model to predict the class for a "new" input ``x_\bullet``: ```math \begin{align*} p(\mathcal{C}_k|x_\bullet,D ) &= \int p(\mathcal{C}_k|x_\bullet,\theta ) p(\theta|D) \mathrm{d}\theta \\ &= \sigma\left( \beta_k^T x_\bullet + \gamma_k\right) \tag{4} \end{align*} ``` where ```math \sigma(a)_k \triangleq \frac{\exp(a_k)}{\sum_{k^\prime}\exp(a_{k^\prime})} ``` is $(HTML("called a")) [**softmax**](https://en.wikipedia.org/wiki/Softmax_function) (a.k.a., **normalized exponential**) function, and ```math \begin{align*} \beta_k &= \hat{\Sigma}^{-1} \hat{\mu}_k \\ \gamma_k &= - \frac{1}{2} \hat{\mu}_k^T \hat{\Sigma}^{-1} \hat{\mu}_k + \log \hat{\pi}_k \end{align*} ``` """Ù$5730758d-80cd-4d95-b16c-399c38cf585b„¨metadataƒ¨disabled©show_logsîskip_as_script§cell_idÙ$5730758d-80cd-4d95-b16c-399c38cf585b«code_foldedäcodeÙ.md""" # Bayesian Generative Classification """Ù$69732524-90fd-46f4-9706-c07ce6226d2b„¨metadataƒ¨disabled©show_logsîskip_as_script§cell_idÙ$69732524-90fd-46f4-9706-c07ce6226d2b«code_foldedäcodeÚUlet # plot training data scatter(X_apples[:,1], X_apples[:,2], label="apple", marker=:x, markerstrokewidth=3) scatter!(X_peaches[:,1], X_peaches[:,2], label="peach", marker=:+, markerstrokewidth=3) plot!(; plot_lims..., legend=:topleft) # plot test point scatter!([x_test[1]], [x_test[2]], label="unknown", c=:yellow, ms=9) end # letÙ$c79525b1-7b44-4585-8292-84abe20a1a3d„¨metadataƒ¨disabled©show_logsîskip_as_script§cell_idÙ$c79525b1-7b44-4585-8292-84abe20a1a3d«code_foldedäcode±md""" Markers """Ù$e8cbfc78-04dd-4196-8011-90283969e5b1„¨metadataƒ¨disabled©show_logsîskip_as_script§cell_idÙ$e8cbfc78-04dd-4196-8011-90283969e5b1«code_foldedäcodeÚpeach_marker = @htl """ """Ù$e65e0e33-3e4f-4765-84ea-a4fb5d43269e„¨metadataƒ¨disabled©show_logsîskip_as_script§cell_idÙ$e65e0e33-3e4f-4765-84ea-a4fb5d43269e«code_foldedäcode°md""" # Code """Ù$10bfb9ea-46a6-4f4d-980e-ed2afce7b39a„¨metadataƒ¨disabled©show_logsîskip_as_script§cell_idÙ$10bfb9ea-46a6-4f4d-980e-ed2afce7b39a«code_folded¤codeÙRd1 = fit_mle(FullNormal, X_apples') # MLE density estimation d1 = N(μâ‚�, Σâ‚�)Ù$cff683bf-0488-41d2-9858-cf8776a48992„¨metadataƒ¨disabled©show_logsîskip_as_script§cell_idÙ$cff683bf-0488-41d2-9858-cf8776a48992«code_folded¤code³X_apples, X_peachesÙ$23c7ab20-d294-11ef-1926-afae49e79923„¨metadataƒ¨disabled©show_logsîskip_as_script§cell_idÙ$23c7ab20-d294-11ef-1926-afae49e79923«code_foldedäcodeÙdmd""" Note that the binary class selection variable ``y_{nk}`` groups data from the same class. """Ù$24a08e5c-c2c1-4f1f-a2c1-998b30147e61„¨metadataƒ¨disabled©show_logsîskip_as_script§cell_idÙ$24a08e5c-c2c1-4f1f-a2c1-998b30147e61«code_foldedäcodeÚ1md""" #### Fanta or Orangina? (**) You have a machine that measures property ``x``, the "orangeness" of liquids. You wish to discriminate between ``C_1 = \text{`Fanta'}`` and ``C_2 = \text{`Orangina'}``. It is known that ```math \begin{align*} p(x|C_1) &= \begin{cases} 10 & 1.0 \leq x \leq 1.1\\ 0 & \text{otherwise} \end{cases}\\ p(x|C_2) &= \begin{cases} 200(x - 1) & 1.0 \leq x \leq 1.1\\ 0 & \text{otherwise} \end{cases} \end{align*} ``` The prior probabilities ``p(C_1) = 0.6`` and ``p(C_2) = 0.4`` are also known from experience. - (a) A "Bayes Classifier" is given by ```math \text{Decision} = \begin{cases} C_1 & \text{if } p(C_1|x)>p(C_2|x) \\ C_2 & \text{otherwise} \end{cases} ``` Derive the optimal Bayes classifier. - (b) The probability of making the wrong decision, given ``x``, is ```math p(\text{error}|x)= p(C_1|\text{we-decide-} C_2, x) + p(C_2|\text{we-decide-}C_1, x) ``` Compute the **total** error probability ``p(\text{error})`` for the Bayes classifier in this example. """Ù$23c85d90-d294-11ef-375e-7101d4d3cbfa„¨metadataƒ¨disabled©show_logsîskip_as_script§cell_idÙ$23c85d90-d294-11ef-375e-7101d4d3cbfa«code_foldedäcodeÚ âmd""" ## Why Be Bayesian? A student in one of the previous years posed the following question at Piazza: > "After re-reading topics regarding generative classification, this question popped into my mind: Besides the sole purpose of the lecture, which is getting to know the concepts of generative classification and how to implement them, are there any advantages of using this instead of using deep neural nets (DNN), as they seem simpler and more powerful?" The following answer was provided: If you are only interested in approximating a function, and you have lots of examples of desired behavior, then often a non-probabilistic DNN is a fine approach. However, if you are willing to formulate your models in a probabilistic framework, you can frequently improve on the deterministic approach in many ways. We list a few below: 1. **Bayesian Evidence as a Performance Metric** - Model performance is evaluated using the evidence ``p(D|m)`` for a model, which inherently balances fit and complexity. This enables the use of the entire dataset for learning: there is no need for arbitrary splits into training and test sets. 2. **Parameter Uncertainty Enables Active Learning** - By maintaining uncertainty over model parameters, Bayesian models support active learning, i.e., the selection of data points that are expected to be most informative (See the [lesson on intelligent agents](https://bmlip.github.io/course/lectures/Intelligent%20Agents%20and%20Active%20Inference.html)). This allows learning from smaller datasets, unlike deterministic deep networks, which often require massive amounts of labeled data. 3. **Predictions with Confidence Bounds** - Bayesian models naturally yield predictive distributions, enabling uncertainty quantification (e.g., confidence intervals) around predictions. 4. **Explicit and Modular Assumptions** - Priors, likelihoods, and structural assumptions are explicitly specified and can be independently modified, promoting transparency and model modularity. 5. **Unified Treatment of Accuracy and Complexity** - Both data fit and model complexity are scored in the same probabilistic units. In contrast, how would you penalize overparameterized architectures (e.g., deep networks) in a deterministic framework? 6. **Data-Dependent, Optimal Learning Rates** - Learning rates emerge naturally from Bayesian updates. Contrast this with the trial-and-error tuning needed in standard optimization. - Example: The Kalman gain is an optimal learning rate based on current uncertainty. 7. **Principled Knowledge Transfer** - Bayesian inference enables posterior-to-prior propagation: results from one experiment (posterior) can inform the next (as a prior). This provides a principled mechanism for sequential learning and integration of heterogeneous information sources. Admittedly, the probabilistic approach can be challenging to grasp at first, but the effort often pays off. It provides a principled, flexible, and robust framework for reasoning under uncertainty. """Ù$1a890e4b-b8a9-4a6e-b1f3-17863e1416d7„¨metadataƒ¨disabled©show_logsîskip_as_script§cell_idÙ$1a890e4b-b8a9-4a6e-b1f3-17863e1416d7«code_foldedäcodeÙCchallenge_solution("Apple or Peach", header_level=1, color="green")Ù$3842654e-6dd7-427c-bb77-8b35a2f324fb„¨metadataƒ¨disabled©show_logsîskip_as_script§cell_idÙ$3842654e-6dd7-427c-bb77-8b35a2f324fb«code_folded¤codeÙ%const Σ_secret = [0.2 0.1; 0.1 0.3];Ù$e91effb4-b3ac-4d7a-b93f-33a78a125110„¨metadataƒ¨disabled©show_logsîskip_as_script§cell_idÙ$e91effb4-b3ac-4d7a-b93f-33a78a125110«code_foldedäcodeÙOmd""" We now have class-conditional Gaussian distributions for each class: """Ù$a985e1d3-4867-4991-a60e-e85a9730311b„¨metadataƒ¨disabled©show_logsîskip_as_script§cell_idÙ$a985e1d3-4867-4991-a60e-e85a9730311b«code_foldedäcodeÚapple_marker = @htl """ """Ù$23c7c920-d294-11ef-1b6d-d98dd54dcbe3„¨metadataƒ¨disabled©show_logsîskip_as_script§cell_idÙ$23c7c920-d294-11ef-1b6d-d98dd54dcbe3«code_foldedäcodeÚmd""" ##### The softmax function The softmax function can be viewed as a smooth approximation to the maximum function. Importantly, we did not impose the softmax posterior by assumption; rather, it emerged naturally by applying Bayes rule to our chosen prior and likelihood models. """Ù$21602809-d98b-43d7-8c41-80dc8de6da57„¨metadataƒ¨disabled©show_logsîskip_as_script§cell_idÙ$21602809-d98b-43d7-8c41-80dc8de6da57«code_foldedäcode¼md""" # Closing Thoughts """Ù$14362031-7977-4a0c-b329-23da9b5b2f62„¨metadataƒ¨disabled©show_logsîskip_as_script§cell_idÙ$14362031-7977-4a0c-b329-23da9b5b2f62«code_foldedäcodeÙ¹keyconcept("", md""" ML estimation for ``\{\pi_k,\mu_k,\Sigma\}`` in the GCM model breaks down to simple density estimation for Gaussian and multinomial/categorical distributions. """)Ù$5092090d-cfac-4ced-b61e-fb7107a4c638„¨metadataƒ¨disabled©show_logsîskip_as_script§cell_idÙ$5092090d-cfac-4ced-b61e-fb7107a4c638«code_foldedäcodeÙ†md""" #### Estimate class-conditional distributions Now, for each class, we fit a Gaussian distribution to the data of that class: """Ù$23c7f170-d294-11ef-1340-fbdf4ce5fd44„¨metadataƒ¨disabled©show_logsîskip_as_script§cell_idÙ$23c7f170-d294-11ef-1340-fbdf4ce5fd44«code_foldedäcodeÚmd""" Therefore, the contours of equal probability (also known as **discriminant functions**, or **decision boundaries**), given by ```math \log \frac{{p(\mathcal{C}_k|x,D )}}{{p(\mathcal{C}_j|x,D )}} \overset{!}{=} 0 \,, ``` are lines (hyperplanes) in the feature space. """Ù$23c82e10-d294-11ef-286a-ff6fee0f2805„¨metadataƒ¨disabled©show_logsîskip_as_script§cell_idÙ$23c82e10-d294-11ef-286a-ff6fee0f2805«code_foldedäcodeÙtmd""" We'll apply the above results to solve the "apple $apple_marker or peach $peach_marker" example problem. """Ù$4481b38d-dc67-4c1f-ac0b-b348f0aea461„¨metadataƒ¨disabled©show_logsîskip_as_script§cell_idÙ$4481b38d-dc67-4c1f-ac0b-b348f0aea461«code_foldedäcodeÙxmd""" ## Implementation Issues We can fit a Bernouilly distribution to [`y` (see definition)](#y), this is simple: """Ù$23c7e4a0-d294-11ef-16e9-6f96a41baf97„¨metadataƒ¨disabled©show_logsîskip_as_script§cell_idÙ$23c7e4a0-d294-11ef-16e9-6f96a41baf97«code_foldedäcodeÙ§md""" ## Discrimination Boundaries The class log-posterior ``\log p(\mathcal{C}_k|x) \propto \beta_k^T x + \gamma_k`` is a linear function of the input features. """Ù$cc8144d9-9ecf-4cbd-aea9-0c7a2fca2d94„¨metadataƒ¨disabled©show_logsîskip_as_script§cell_idÙ$cc8144d9-9ecf-4cbd-aea9-0c7a2fca2d94«code_folded¤codeÙLp_apple_est = sum(y) / length(y) # or: p_apple_est = fit_mle(Bernoulli, y).pÙ$46d2d5e9-bb6b-409a-acdc-cdffd1a6f797„¨metadataƒ¨disabled©show_logsîskip_as_script§cell_idÙ$46d2d5e9-bb6b-409a-acdc-cdffd1a6f797«code_folded¤codeÙ]conditionals = [ MvNormal(mean(d1), Σ_computed) MvNormal(mean(d2), Σ_computed) ] # p(x|C)Ù$6631c0e4-4941-442e-8dd4-fa307ee7a8c0„¨metadataƒ¨disabled©show_logsîskip_as_script§cell_idÙ$6631c0e4-4941-442e-8dd4-fa307ee7a8c0«code_folded¤code¬using RandomÙ$358fac57-7458-40b5-9f69-50ad4ca7edde„¨metadataƒ¨disabled©show_logsîskip_as_script§cell_idÙ$358fac57-7458-40b5-9f69-50ad4ca7edde«code_foldedäcode³keyconceptsummary()Ù$25e18c78-9cac-4faa-bb7c-ac036d0eac90„¨metadataƒ¨disabled©show_logsîskip_as_script§cell_idÙ$25e18c78-9cac-4faa-bb7c-ac036d0eac90«code_foldedäcodeÚÐhide_solution( md""" ```math \begin{align} &\log \frac{{p(\mathcal{C}_k|x,D )}}{{p(\mathcal{C}_j|x,D )}} \overset{!}{=} 0 \\ \implies &\frac{\beta_k^T x + \gamma_k}{\beta_j^T x + \gamma_j} = 1 \\ \implies &\beta_k^T x + \gamma_k = \beta_j^T x + \gamma_j \\ \implies &\beta_{kj}^T x + \gamma_{kj} = 0 \quad \text{(this is a line)}\,, \end{align} ``` where we defined ``\beta_{kj} \triangleq \beta_k - \beta_j`` and similarly for ``\gamma_{kj}``. """ )Ù$a42ec280-a88a-485b-9f34-219b370e5784„¨metadataƒ¨disabled©show_logsîskip_as_script§cell_idÙ$a42ec280-a88a-485b-9f34-219b370e5784«code_foldedäcodeÙ¢navigate_prev_next( "https://bmlip.github.io/course/lectures/Regression.html", "https://bmlip.github.io/course/lectures/Discriminative%20Classification.html", )Ù$ef1e5885-7153-4b55-9f97-1e984c2504e6„¨metadataƒ¨disabled©show_logsîskip_as_script§cell_idÙ$ef1e5885-7153-4b55-9f97-1e984c2504e6«code_foldedäcodeÚ[hide_solution( md""" Substitute 4.64 into 4.58 to get ```math \begin{align*} a &= \log \left( \frac{ \frac{1}{(2\pi)^{D/2}} \cdot \frac{1}{|\Sigma|^{1/2}} \cdot \exp\left( -\frac{1}{2}(x-\mu_1)^T \Sigma^{-1} (x-\mu_1)\right) \cdot p(C_1)}{\frac{1}{(2\pi)^{D/2}} \cdot \frac{1}{|\Sigma|^{1/2}}\cdot \exp\left( -\frac{1}{2}(x-\mu_2)^T \Sigma^{-1} (x-\mu_2)\right) \cdot p(C_2)}\right) \\ &= \log \left( \exp\left(-\frac{1}{2}(x-\mu_1)^T \Sigma^{-1} (x-\mu_1) + \frac{1}{2}(x-\mu_2)^T \Sigma^{-1} (x-\mu_2) \right) \right) + \log \frac{p(C_1)}{p(C_2)} \\ &\qquad\vdots \\ &=( \mu_1-\mu_2)^T\Sigma^{-1}x - 0.5\left(\mu_1^T\Sigma^{-1}\mu_1 - \mu_2^T\Sigma^{-1} \mu_2\right)+ \log \frac{p(C_1)}{p(C_2)} \end{align*} ``` Substituting this into the right-most form of (4.57) we obtain (4.65), with ``w`` and ``w0`` given by (4.66) and (4.67), respectively. """)Ù$23c82154-d294-11ef-0945-c9c94fc2a44d„¨metadataƒ¨disabled©show_logsîskip_as_script§cell_idÙ$23c82154-d294-11ef-0945-c9c94fc2a44d«code_foldedäcodeÚòmd""" #### Making a Decision How should we classify a new input ``x_\bullet``? The Bayesian answer is to compute the posterior distribution over classes, ```math p(\mathcal{C}_k | x_\bullet,D)\,, ``` and this completes the classification task: the posterior encapsulates all available information about class membership given the input and data. If a definite classification **must** be made, a natural choice is the class with the highest posterior probability: ```math \begin{align*} k^* &= \arg\max_k p(\mathcal{C}_k|x_\bullet,D) \\ &= \arg\max_k \left( \beta _k^T x_\bullet + \gamma_k \right) \end{align*} ``` This corresponds to a maximum a posteriori (MAP) decision rule, which is both simple and effective in many practical settings. """Ù$50cbe27e-009f-4df1-b80a-cf1e73fc525e„¨metadataƒ¨disabled©show_logsîskip_as_script§cell_idÙ$50cbe27e-009f-4df1-b80a-cf1e73fc525e«code_folded¤code²using LaTeXStringsÙ$bf39f423-7df3-4990-a254-c28a1bdf23bf„¨metadataƒ¨disabled©show_logsîskip_as_script§cell_idÙ$bf39f423-7df3-4990-a254-c28a1bdf23bf«code_folded¤code¦x_testÙ$90b862a5-d5bc-4122-a942-f01062daa86a„¨metadataƒ¨disabled©show_logsîskip_as_script§cell_idÙ$90b862a5-d5bc-4122-a942-f01062daa86a«code_foldedäcodeÙ¿md""" ### Posterior class probability of ``x_∙`` (prediction) Now we can answer the question from the challenge, and calculate the probability that ``x_∙`` is an apple $apple_marker. """Ù$b01a4a56-bed2-4a06-991a-831adc84aa3e„¨metadataƒ¨disabled©show_logsîskip_as_script§cell_idÙ$b01a4a56-bed2-4a06-991a-831adc84aa3e«code_foldedäcodeÚhide_solution( md""" Following the same derivation as above (in the cell "Click for proof of (4)"), the posterior class probability evaluates to ```math \begin{align*} p(\mathcal{C}_k|x_\bullet,D ) \propto \exp \Big\{ \underbrace{-\frac{1}{2}x_\bullet^T \hat{\Sigma}_k^{ - 1} x_\bullet}_{\text{now a function of }k} + \underbrace{\hat{\mu}_k^T \hat{\Sigma}_k^{-1}}_{\beta_k^T} x_\bullet \underbrace{- {\frac{1}{2}}\hat{\mu}_k^T \hat{\Sigma}_k^{ - 1} \hat{\mu}_k + \log \hat{\pi}_k }_{\gamma_k} \Big\} \,. \end{align*} ``` Because the quadratic term ``x_\bullet^T \hat{\Sigma}_k^{-1} x_\bullet`` is now class-dependent, the decision boundaries are given by quadratic equations in ``x``. Hence, the decision boundaries are generally (hyper-)ellipsoid surfaces. """ )Ù$117f3f65-a9bd-4b25-93e2-42ac1e576b6d„¨metadataƒ¨disabled©show_logsîskip_as_script§cell_idÙ$117f3f65-a9bd-4b25-93e2-42ac1e576b6d«code_foldedäcodeÙÞkeyconcept("", md""" If the class-conditional distributions are Gaussian with equal covariance matrices across classes (i.e., ``\Sigma_k = \Sigma``), then the discriminant functions are hyperplanes in feature space. """)Ù$fe324e92-d753-46cd-aad9-794a76dc806b„¨metadataƒ¨disabled©show_logsîskip_as_script§cell_idÙ$fe324e92-d753-46cd-aad9-794a76dc806b«code_foldedäcodeÙ{md""" You are also given a test fruit $unknown_marker, which has known feature values but an **unknown fruit label**. """Ù$a8adaf31-bee2-40e9-8d9b-bb9f1ad996ca„¨metadataƒ¨disabled©show_logsîskip_as_script§cell_idÙ$a8adaf31-bee2-40e9-8d9b-bb9f1ad996ca«code_foldedäcodeÚmd""" Now assume that the class-conditional feature distributions are modeled with class-dependent covariance matrices, i.e., ```math p(x_n|\mathcal{C}_{k}) = \mathcal{N}(x_n|\mu_k,\Sigma_k) ``` What do the decision boundaries look like in this case? """Ù$7e5213d6-4a68-4843-ab4c-77ea3ed8b0cd„¨metadataƒ¨disabled©show_logsîskip_as_script§cell_idÙ$7e5213d6-4a68-4843-ab4c-77ea3ed8b0cd«code_foldedäcodeÚ¦md""" #### [Bishop exercise 4.8](https://www.microsoft.com/en-us/research/wp-content/uploads/2006/01/Bishop-Pattern-Recognition-and-Machine-Learning-2006.pdf#page=241) (**) Using (4.57) and (4.58) (from Bishop's book), derive the result (4.65) for the posterior class probability in the two-class generative model with Gaussian densities, and verify the results (4.66) and (4.67) for the parameters ``w`` and ``w0``. """Ù$f1575443-c9fb-4674-bbce-bf3a5a6d5a8d„¨metadataƒ¨disabled©show_logsîskip_as_script§cell_idÙ$f1575443-c9fb-4674-bbce-bf3a5a6d5a8d«code_folded¤codeºusing Plots, DistributionsÙ$23c73b54-d294-11ef-0ef8-8d9159139a1b„¨metadataƒ¨disabled©show_logsîskip_as_script§cell_idÙ$23c73b54-d294-11ef-0ef8-8d9159139a1b«code_foldedäcodeÚßmd""" ## Model Specification #### Representation The above data set will be represented as ``D = \{(x_1,y_1),\dotsc,(x_N,y_N)\}``, where * inputs ``x_n \in \mathbb{R}^M`` are called **features**. * outputs ``y_n \in \mathcal{C}_k``, with ``k=1,\ldots,K``; The **discrete** targets ``\mathcal{C}_k`` are called **classes**. Similar to our representation of the categorical distribution, we will again use the 1-of-K (or one-hot) encoding to represent the discrete class labels. We define binary **class selection variables** ```math y_{nk} = \begin{cases} 1 & \text{if } \, y_n \in \mathcal{C}_k\\ 0 & \text{otherwise} \end{cases} ``` Hence, the notations ``y_{nk}=1`` and ``y_n \in \mathcal{C}_k`` mean the same thing. """Ù$77280f3b-e391-482f-936f-703d1d3c4006„¨metadataƒ¨disabled©show_logsîskip_as_script§cell_idÙ$77280f3b-e391-482f-936f-703d1d3c4006«code_foldedäcodeÙómd""" ##### Problem - Based on the observed data, what is the probability that the test fruit is an apple $apple_marker, and not a peach $peach_marker? ##### Solution - [Later in this lecture](#Challenge-Revisited:-Apple-or-Peach). """Ù$24d3c1f4-432f-419f-8854-69d8bfc135f8„¨metadataƒ¨disabled©show_logsîskip_as_script§cell_idÙ$24d3c1f4-432f-419f-8854-69d8bfc135f8«code_folded¤codeÙMX_apples, X_peaches = collect(X[:,findall(y)]'), collect(X[:,findall(.!y)]');Ù$23c73302-d294-11ef-0c12-571686b202a9„¨metadataƒ¨disabled©show_logsîskip_as_script§cell_idÙ$23c73302-d294-11ef-0c12-571686b202a9«code_foldedäcodeÚ¥md""" The plan for generative classification is as follows: We begin by constructing a model for the joint distribution ```math p(x, y) = p(x | y)\, p(y), ``` which combines a **class-conditional likelihood** ``p(x | y)`` with a **prior** ``p(y)`` over classes. Then, we apply Bayes rule to compute the posterior class probabilities, ```math p(y|x) = \frac{p(x|y) p(y)}{\sum_{y^\prime} p(x|y^\prime) p(y^\prime)} \propto p(x|y)\,p(y) ``` This posterior can then be used for classification by selecting the class with the highest probability. Next, we discuss the three modeling stages: (1) model specification, (2) parameter learning, (3) application (classification). """Ù$fedb7530-6fce-496c-a55a-3e9908f9711a„¨metadataƒ¨disabled©show_logsîskip_as_script§cell_idÙ$fedb7530-6fce-496c-a55a-3e9908f9711a«code_folded¤code±y .|> Int |> joinÙ$23c75dc8-d294-11ef-3c57-614e75f06d8f„¨metadataƒ¨disabled©show_logsîskip_as_script§cell_idÙ$23c75dc8-d294-11ef-3c57-614e75f06d8f«code_foldedäcodeÚfmd""" We will refer to this model (specified by Eqs. 1 and 2) as the **Gaussian-Categorical Model** ($(HTML("GCM"))). * N.B. In the literature, this model (with possibly unequal ``\Sigma_k`` across classes) is often called the Gaussian Discriminant Analysis model and the special case with equal covariance matrices ``\Sigma_k=\Sigma`` is also called Linear Discriminant Analysis. We think these names are a bit unfortunate as it may lead to confusion with the [discriminative method for classification](https://bmlip.github.io/course/lectures/Discriminative%20Classification.html). """Ù$79fa1b47-460f-457e-aebc-646f60ffecc1„¨metadataƒ¨disabled©show_logsîskip_as_script§cell_idÙ$79fa1b47-460f-457e-aebc-646f60ffecc1«code_foldedäcodeÙéunknown_marker = @htl """ """Ù$d9efe8bb-c32c-40f4-89d9-8ace7a0665ba„¨metadataƒ¨disabled©show_logsîskip_as_script§cell_idÙ$d9efe8bb-c32c-40f4-89d9-8ace7a0665ba«code_folded¤codeÙ2x_test = [2.3; 1.5] # Features of 'new' data pointÙ$23c74748-d294-11ef-2170-bf45b6379e4d„¨metadataƒ¨disabled©show_logsîskip_as_script§cell_idÙ$23c74748-d294-11ef-2170-bf45b6379e4d«code_foldedäcodeÙŠmd""" #### Prior We use a categorical distribution for the class labels ``y_{nk}``: ```math p(\mathcal{C}_{k}) = \pi_k \tag{2} ``` """Ù$9973e8e5-4744-4ff6-9494-1c93503f11c1„¨metadataƒ¨disabled©show_logsîskip_as_script§cell_idÙ$9973e8e5-4744-4ff6-9494-1c93503f11c1«code_foldedäcodeÙtmd""" We can use this function on every point of the plot, to draw a heatmap of apple $apple_marker probability: """Ù$723e09fc-ec63-4c47-844c-d821515ce0f4„¨metadataƒ¨disabled©show_logsîskip_as_script§cell_idÙ$723e09fc-ec63-4c47-844c-d821515ce0f4«code_foldedäcodeÙR@mdx("``p(\\text{apple}|x=x_∙) = $(round(predict_class(1,x_test), digits=3))``")Ù$876f47d8-b272-4e23-b5ec-5c7d615ff618„¨metadataƒ¨disabled©show_logsîskip_as_script§cell_idÙ$876f47d8-b272-4e23-b5ec-5c7d615ff618«code_foldedäcodeÙJbegin N_bond = @bindname N Slider(1:250; show_value=true, default=50) endÙ$f7a19975-a919-4659-9b6a-d8963a1cd6d9„¨metadataƒ¨disabled©show_logsîskip_as_script§cell_idÙ$f7a19975-a919-4659-9b6a-d8963a1cd6d9«code_foldedäcodeÙFchallenge_statement("Apple or Peach?" , color= "red", header_level=1 )Ù$23c78d3e-d294-11ef-0309-ff10f58f0252„¨metadataƒ¨disabled©show_logsîskip_as_script§cell_idÙ$23c78d3e-d294-11ef-0309-ff10f58f0252«code_foldedäcodeÚýmd""" #### Maximization of log-likelihood Maximization of the LLH for the GDA model breaks down into * **Gaussian density estimation** for parameters ``\mu_k, \Sigma``, since the first term contains exactly the log-likelihood for MVG density estimation. We've already done this; see the [Density Estimation lesson](https://bmlip.github.io/course/lectures/Density%20Estimation.html#Gaussian-Maximum-Likelihood-Estimation). * **Multinomial density estimation** for class priors ``\pi_k``, since the second term holds exactly the log-likelihood for multinomial density estimation. We've also done this before; see the [Density Estimation lesson](https://bmlip.github.io/course/lectures/Density%20Estimation.html#Multinomial-Maximum-Likelihood-Estimation). """Ù$689ea1f9-0a72-478e-b8a9-ebf450ce95ef„¨metadataƒ¨disabled©show_logsîskip_as_script§cell_idÙ$689ea1f9-0a72-478e-b8a9-ebf450ce95ef«code_foldedäcode¦N_bondÙ$5c746070-19a9-464b-aedc-401d016dfdb6„¨metadataƒ¨disabled©show_logsîskip_as_script§cell_idÙ$5c746070-19a9-464b-aedc-401d016dfdb6«code_foldedäcodeÙRexercise_statement("Discrimination boundaries" , color= "yellow", header_level=4 )Ù$2f2cb20f-ff7c-4b7f-8aa0-f5b3addb9299„¨metadataƒ¨disabled©show_logsîskip_as_script§cell_idÙ$2f2cb20f-ff7c-4b7f-8aa0-f5b3addb9299«code_foldedäcodeÙANotebookCard("https://bmlip.github.io/course/minis/Softmax.html")Ù$2e1ccf78-6097-4097-8bc8-1f1ec2d9c3ff„¨metadataƒ¨disabled©show_logsîskip_as_script§cell_idÙ$2e1ccf78-6097-4097-8bc8-1f1ec2d9c3ff«code_foldedäcodeÚPmd""" Show that the log-likelihood for the parameters evaluates to ```math \log\, p(D|\theta) = \sum_{n,k} y_{nk} \underbrace{ \log\mathcal{N}(x_n|\mu_k,\Sigma) }_{ \text{see Gaussian lecture} } + \underbrace{ \sum_k m_k \log \pi_k }_{ \text{see multinomial lecture} } \tag{3} ``` where we used ``m_k \triangleq \sum_n y_{nk}``. """Ù$84353cd1-e4fb-4689-9e90-d8995cbe2e9b„¨metadataƒ¨disabled©show_logsîskip_as_script§cell_idÙ$84353cd1-e4fb-4689-9e90-d8995cbe2e9b«code_foldedäcodeÚÓdetails("Click for proof of (4)", md""" ```math \begin{align*} p(\mathcal{C}_k|x_\bullet,D ) &= \int p(\mathcal{C}_k|x_\bullet,\theta ) \underbrace{p(\theta|D)}_{=\delta(\theta - \hat{\theta})} \mathrm{d}\theta \\ &= p(\mathcal{C}_k|x_\bullet,\hat{\theta} ) \\ &\propto p(\mathcal{C}_k)\,p(x_\bullet|\mathcal{C}_k) \\ &= \hat{\pi}_k \cdot \mathcal{N}(x_\bullet | \hat{\mu}_k, \hat{\Sigma}) \\ &\propto \hat{\pi}_k \exp \left\{ { - {\frac{1}{2}}(x_\bullet - \hat{\mu}_k )^T \hat{\Sigma}^{ - 1} (x_\bullet - \hat{\mu}_k )} \right\}\\ &=\exp \Big\{ \underbrace{-\frac{1}{2}x_\bullet^T \hat{\Sigma}^{ - 1} x_\bullet}_{\text{not a function of }k} + \underbrace{\hat{\mu}_k^T \hat{\Sigma}^{-1}}_{\beta_k^T} x_\bullet \underbrace{- {\frac{1}{2}}\hat{\mu}_k^T \hat{\Sigma}^{ - 1} \hat{\mu}_k + \log \hat{\pi}_k }_{\gamma_k} \Big\} \\ &\propto \frac{1}{Z}\exp\{\beta_k^T x_\bullet + \gamma_k\} \\ &= \sigma\left( \beta_k^T x_\bullet + \gamma_k\right) \end{align*} ``` """ ) Ù$51a46b5e-0c35-4841-a4f3-413d5d294805„¨metadataƒ¨disabled©show_logsîskip_as_script§cell_idÙ$51a46b5e-0c35-4841-a4f3-413d5d294805«code_foldedäcodeÚ$md""" You're given the numerical values for two features (let's say, _sugar content_ and _acidity_) of a bunch of fruits. Each piece of fruit is either an apple $apple_marker or a peach $peach_marker. Generate this data yourself by selecting the total number of fruits with the slider: """Ù$32cb67f6-1ed2-4d30-8493-e4eed9651526„¨metadataƒ¨disabled©show_logsîskip_as_script§cell_idÙ$32cb67f6-1ed2-4d30-8493-e4eed9651526«code_foldedäcodeÚRhide_solution( md""" ```math \begin{align*} \log\, p(D|\theta) &= \log \prod_n p(x_n,y_n|\theta ) \quad \text{(assume IID data)} \\ &= \sum_n \log p(x_n,y_n|\theta ) \\ &= \sum_n \log \prod_k p(x_n,y_{nk}=1\,|\,\theta)^{y_{nk}} \\ &= \sum_{n,k} y_{nk} \log p(x_n,y_{nk}=1\,|\,\theta) \\ &= \sum_{n,k} y_{nk} \log p(x_n|y_{nk}=1) + \sum_{n,k} y_{nk} \log p(y_{nk}=1) \\ &= \sum_{n,k} y_{nk} \log\mathcal{N}(x_n|\mu_k,\Sigma) + \sum_{n,k} y_{nk} \log \pi_k \\ &= \sum_{n,k} y_{nk} \log\mathcal{N}(x_n|\mu_k,\Sigma)+ \sum_k m_k \log \pi_k \end{align*} ``` """ )Ù$26853cdc-0644-4f44-b6db-b5624a4a8689„¨metadataƒ¨disabled©show_logsîskip_as_script§cell_idÙ$26853cdc-0644-4f44-b6db-b5624a4a8689«code_folded¤code»using MarkdownLiteral: @mdxÙ$cd310392-aabd-40e0-b06f-f8297c7eed6f„¨metadataƒ¨disabled©show_logsîskip_as_script§cell_idÙ$cd310392-aabd-40e0-b06f-f8297c7eed6f«code_folded¤codeÙRd2 = fit_mle(FullNormal, X_peaches') # MLE density estimation d2 = N(μ₂, Σ₂)Ù$a4463d74-04ea-428a-b5a5-504d96432a0a„¨metadataƒ¨disabled©show_logsîskip_as_script§cell_idÙ$a4463d74-04ea-428a-b5a5-504d96432a0a«code_foldedäcodeÙŸmd""" Our data is structured as follows: - ``y`` is whether a data point is an apple (`true`) or a peach (`false`) - ``x`` has one column of data per fruit """Ù$45f1f80d-18fc-465c-aaf3-54bbcd8bc95e„¨metadataƒ¨disabled©show_logsîskip_as_script§cell_idÙ$45f1f80d-18fc-465c-aaf3-54bbcd8bc95e«code_foldedäcode³md""" # Summary """´last_hot_reload_timeË©shortpath¼Generative Classification.jl¥nbpkgŠ­busy_packages�Ù,waiting_for_permission_but_probably_disabled§enabledðterminal_outputs‡¯MarkdownLiteralÚ Resolving... ===  Project No packages added to or removed from `~/.julia/scratchspaces/c3e4b0f8-55cb-11ea-2926-15256bba5781/pkg_envs/env_yygfbqjlep/Project.toml`  Manifest No packages added to or removed from `~/.julia/scratchspaces/c3e4b0f8-55cb-11ea-2926-15256bba5781/pkg_envs/env_yygfbqjlep/Manifest.toml` Instantiating... === Precompiling... === Waiting for notebook process to start... Done. Starting precompilation...¦RandomÚ Resolving... ===  Project No packages added to or removed from `~/.julia/scratchspaces/c3e4b0f8-55cb-11ea-2926-15256bba5781/pkg_envs/env_yygfbqjlep/Project.toml`  Manifest No packages added to or removed from `~/.julia/scratchspaces/c3e4b0f8-55cb-11ea-2926-15256bba5781/pkg_envs/env_yygfbqjlep/Manifest.toml` Instantiating... === Precompiling... === Waiting for notebook process to start... Done. Starting precompilation...ªnbpkg_syncÚ Resolving... ===  Project No packages added to or removed from `~/.julia/scratchspaces/c3e4b0f8-55cb-11ea-2926-15256bba5781/pkg_envs/env_yygfbqjlep/Project.toml`  Manifest No packages added to or removed from `~/.julia/scratchspaces/c3e4b0f8-55cb-11ea-2926-15256bba5781/pkg_envs/env_yygfbqjlep/Manifest.toml` Instantiating... === Precompiling... === Waiting for notebook process to start... Done. Starting precompilation...²BmlipTeachingToolsÚ Resolving... ===  Project No packages added to or removed from `~/.julia/scratchspaces/c3e4b0f8-55cb-11ea-2926-15256bba5781/pkg_envs/env_yygfbqjlep/Project.toml`  Manifest No packages added to or removed from `~/.julia/scratchspaces/c3e4b0f8-55cb-11ea-2926-15256bba5781/pkg_envs/env_yygfbqjlep/Manifest.toml` Instantiating... === Precompiling... === Waiting for notebook process to start... Done. Starting precompilation...¬LaTeXStringsÚ Resolving... ===  Project No packages added to or removed from `~/.julia/scratchspaces/c3e4b0f8-55cb-11ea-2926-15256bba5781/pkg_envs/env_yygfbqjlep/Project.toml`  Manifest No packages added to or removed from `~/.julia/scratchspaces/c3e4b0f8-55cb-11ea-2926-15256bba5781/pkg_envs/env_yygfbqjlep/Manifest.toml` Instantiating... === Precompiling... === Waiting for notebook process to start... Done. Starting precompilation...­DistributionsÚ Resolving... ===  Project No packages added to or removed from `~/.julia/scratchspaces/c3e4b0f8-55cb-11ea-2926-15256bba5781/pkg_envs/env_yygfbqjlep/Project.toml`  Manifest No packages added to or removed from `~/.julia/scratchspaces/c3e4b0f8-55cb-11ea-2926-15256bba5781/pkg_envs/env_yygfbqjlep/Manifest.toml` Instantiating... === Precompiling... === Waiting for notebook process to start... Done. Starting precompilation...¥PlotsÚ Resolving... ===  Project No packages added to or removed from `~/.julia/scratchspaces/c3e4b0f8-55cb-11ea-2926-15256bba5781/pkg_envs/env_yygfbqjlep/Project.toml`  Manifest No packages added to or removed from `~/.julia/scratchspaces/c3e4b0f8-55cb-11ea-2926-15256bba5781/pkg_envs/env_yygfbqjlep/Manifest.toml` Instantiating... === Precompiling... === Waiting for notebook process to start... Done. Starting precompilation...¶waiting_for_permission·restart_recommended_msgÀ´restart_required_msgÀ²installed_versionsˆ¯MarkdownLiteral¥0.1.5¸__internal_julia_version¦1.13.3¦Random¦stdlib²BmlipTeachingTools¥1.4.1¬LaTeXStrings¥1.4.1­Distributions¨0.25.132¥Plots¦1.41.7Ù!__internal_julia_manifest_version¦1.13.3¯install_time_nsÎÖa¡¬instantiatedípluto_version¦v1.1.0